Skip to content

Commit 5e33485

Browse files
authored
Release/1.0.17 (#152)
* Added repo example * Corrected repo example * ParseResponse accepts list results and count * Private/test (#140) * ParseResponse accepts list results and count * Corrected toPointer logic * Corrected date issue * Code clean * Code clean * Private/test (#141) * ParseResponse accepts list results and count * Corrected toPointer logic * Corrected date issue * Code clean * Code clean * Code clean * Fixed delete * Fixed ParseUser setting ParseObject extensions * Fix lost lat, lng data (#143) Update so SubClass of ParseObject uses internal Map for value storage. Changes in v1.0.17 breaks ParseGeoPoint. This is tested and seems to fix the issue. * Deprecated result * Corrected logic on response * ParseFile fix * Removed protected * Testing ParseUser conversion * Fixed ParseFile code saving * ParseInstallation fix * ParseUser supporting custom user objects * Add Support to Relational Queries / Counting Objects (#146) * Add Support to Relational Queries Add Support to Relational Queries * Add Support to Counting Objects Add Support to Counting Objects https://docs.parseplatform.org/rest/guide/#counting-objects * Update the documentation with Relational Queries and Count Objects (#147) * Add Support to Relational Queries Add Support to Relational Queries * Add Support to Counting Objects Add Support to Counting Objects https://docs.parseplatform.org/rest/guide/#counting-objects * Update README.md Update documentation with example for Relational Queries and Counting Objects * Update README.md * Update README.md - Small typo (#148) * Add Support to Relational Queries Add Support to Relational Queries * Add Support to Counting Objects Add Support to Counting Objects https://docs.parseplatform.org/rest/guide/#counting-objects * Update README.md Update documentation with example for Relational Queries and Counting Objects * Update README.md * Update README.md * BugFix LiveQuery - update readme.md (#150) * Add Support to Relational Queries Add Support to Relational Queries * Add Support to Counting Objects Add Support to Counting Objects https://docs.parseplatform.org/rest/guide/#counting-objects * Update README.md Update documentation with example for Relational Queries and Counting Objects * Update README.md * Update README.md * BugFix LiveQuery BugFix LiveQuery * Bugfix LiveQuery Bugfix LiveQuery * Update README.md Reorganization of sessions and inclusion of documentation on LiveQuery * Update README.md * Update README.md * Bugfix LiveQuery Bugfix LiveQuery * Changed to make optional clientKey Changed to make optional clientKey * Bugfix parseEncode function with ParseObjects in List (#151) * Add Support to Relational Queries Add Support to Relational Queries * Add Support to Counting Objects Add Support to Counting Objects https://docs.parseplatform.org/rest/guide/#counting-objects * Update README.md Update documentation with example for Relational Queries and Counting Objects * Update README.md * Update README.md * BugFix LiveQuery BugFix LiveQuery * Bugfix LiveQuery Bugfix LiveQuery * Update README.md Reorganization of sessions and inclusion of documentation on LiveQuery * Update README.md * Update README.md * Bugfix LiveQuery Bugfix LiveQuery * Changed to make optional clientKey Changed to make optional clientKey * Bugfix parseEncode function with ParseObjects in List Bugfix parseEncode function with ParseObjects in List * 1.0.17 - Cody tidy * ParseResponse accepts list results and count
1 parent 1723780 commit 5e33485

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2217
-301
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.17
2+
3+
14
## 1.0.16
25
Bug fixes
36
Fixed object delete

README.md

Lines changed: 231 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse
1313
To install, either add to your pubspec.yaml
1414
```yml
1515
dependencies:
16-
parse_server_sdk: ^1.0.16
16+
parse_server_sdk: ^1.0.17
1717
```
1818
or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added.
1919
@@ -35,11 +35,95 @@ Parse().initialize(
3535
masterKey: ApplicationConstants.keyParseMasterKey,
3636
clientKey: ApplicationConstants.keyParseClientKey,
3737
debug: true,
38-
liveQuery: true,
38+
liveQueryUrl: ApplicationConstants.keyLiveQueryUrl,
3939
autoSendSessionId: true,
4040
securityContext: securityContext);
4141
```
4242

43+
## Objects
44+
You can create custom objects by calling:
45+
```dart
46+
var dietPlan = ParseObject('DietPlan')
47+
..set('Name', 'Ketogenic')
48+
..set('Fat', 65);
49+
```
50+
You then have the ability to do the following with that object:
51+
The features available are:-
52+
* Get
53+
* GetAll
54+
* Create
55+
* Save
56+
* Query - By object Id
57+
* Delete
58+
* Complex queries as shown above
59+
* Pin
60+
* Plenty more
61+
* Counters
62+
* Array Operators
63+
64+
## Custom Objects
65+
You can create your own ParseObjects or convert your existing objects into Parse Objects by doing the following:
66+
67+
```dart
68+
class DietPlan extends ParseObject implements ParseCloneable {
69+
70+
DietPlan() : super(_keyTableName);
71+
DietPlan.clone(): this();
72+
73+
/// Looks strangely hacky but due to Flutter not using reflection, we have to
74+
/// mimic a clone
75+
@override clone(Map map) => DietPlan.clone()..fromJson(map);
76+
77+
static const String _keyTableName = 'Diet_Plans';
78+
static const String keyName = 'Name';
79+
80+
String get name => get<String>(keyName);
81+
set name(String name) => set<String>(keyName, name);
82+
}
83+
84+
```
85+
86+
## Add new values to objects
87+
To add a variable to an object call and retrieve it, call
88+
89+
```dart
90+
dietPlan.set<int>('RandomInt', 8);
91+
var randomInt = dietPlan.get<int>('RandomInt');
92+
```
93+
94+
## Save objects using pins
95+
You can now save an object by calling .pin() on an instance of an object
96+
97+
```dart
98+
dietPlan.pin();
99+
```
100+
101+
and to retrieve it
102+
103+
```dart
104+
var dietPlan = DietPlan().fromPin('OBJECT ID OF OBJECT');
105+
```
106+
107+
## Increment Counter values in objects
108+
Retrieve it, call
109+
110+
```dart
111+
var response = await dietPlan.increment("count", 1);
112+
113+
```
114+
115+
## Array Operator in objects
116+
Retrieve it, call
117+
118+
```dart
119+
var response = await dietPlan.add("listKeywords", ["a", "a","d"]);
120+
121+
var response = await dietPlan.addUnique("listKeywords", ["a", "a","d"]);
122+
123+
var response = await dietPlan.remove("listKeywords", ["a"]);
124+
125+
```
126+
43127
## Queries
44128
Once you have setup the project and initialised the instance, you can then retreive data from your server by calling:
45129
```dart
@@ -63,7 +147,6 @@ var dietPlan = await DietPlan().getObject('R5EonpUDWy');
63147
}
64148
```
65149

66-
67150
## Complex queries
68151
You can create complex queries to really put your database to the test:
69152

@@ -106,99 +189,185 @@ The features available are:-
106189
* Ascending
107190
* Descending
108191
* Plenty more!
192+
193+
## Relational queries
194+
If you want to retrieve objects where a field contains an object that matches another query, you can use the
195+
__whereMatchesQuery__ condition.
196+
For example, imagine you have Post class and a Comment class, where each Comment has a pointer to its parent Post.
197+
You can find comments on posts with images by doing:
109198

110-
## Objects
111-
112-
You can create custom objects by calling:
113199
```dart
114-
var dietPlan = ParseObject('DietPlan')
115-
..set('Name', 'Ketogenic')
116-
..set('Fat', 65);
200+
QueryBuilder<ParseObject> queryPost =
201+
QueryBuilder<ParseObject>(ParseObject('Post'))
202+
..whereValueExists('image', true);
203+
204+
QueryBuilder<ParseObject> queryComment =
205+
QueryBuilder<ParseObject>(ParseObject('Comment'))
206+
..whereMatchesQuery('post', queryPost);
207+
208+
var apiResponse = await queryComment.query();
117209
```
118-
You then have the ability to do the following with that object:
119-
The features available are:-
120-
* Get
121-
* GetAll
122-
* Create
123-
* Save
124-
* Query - By object Id
125-
* Delete
126-
* Complex queries as shown above
127-
* Pin
128-
* Plenty more
129-
* Counters
130-
* Array Operators
131210

132-
## Custom Objects
133-
You can create your own ParseObjects or convert your existing objects into Parse Objects by doing the following:
211+
If you want to retrieve objects where a field contains an object that does not match another query, you can use the
212+
__whereDoesNotMatchQuery__ condition.
213+
Imagine you have Post class and a Comment class, where each Comment has a pointer to its parent Post.
214+
You can find comments on posts without images by doing:
134215

135216
```dart
136-
class DietPlan extends ParseObject implements ParseCloneable {
217+
QueryBuilder<ParseObject> queryPost =
218+
QueryBuilder<ParseObject>(ParseObject('Post'))
219+
..whereValueExists('image', true);
137220
138-
DietPlan() : super(_keyTableName);
139-
DietPlan.clone(): this();
140-
141-
/// Looks strangely hacky but due to Flutter not using reflection, we have to
142-
/// mimic a clone
143-
@override clone(Map map) => DietPlan.clone()..fromJson(map);
221+
QueryBuilder<ParseObject> queryComment =
222+
QueryBuilder<ParseObject>(ParseObject('Comment'))
223+
..whereDoesNotMatchQuery('post', queryPost);
144224
145-
static const String _keyTableName = 'Diet_Plans';
146-
static const String keyName = 'Name';
147-
148-
String get name => get<String>(keyName);
149-
set name(String name) => set<String>(keyName, name);
150-
}
151-
225+
var apiResponse = await queryComment.query();
152226
```
153227

154-
## Add new values to objects
155-
156-
To add a variable to an object call and retrieve it, call
228+
## Counting Objects
229+
If you only care about the number of games played by a particular player:
157230

158231
```dart
159-
dietPlan.set<int>('RandomInt', 8);
160-
var randomInt = dietPlan.get<int>('RandomInt');
232+
QueryBuilder<ParseObject> queryPlayers =
233+
QueryBuilder<ParseObject>(ParseObject('GameScore'))
234+
..whereEqualTo('playerName', 'Jonathan Walsh');
235+
var apiResponse = await queryPlayers.count();
236+
if (apiResponse.success && apiResponse.result != null) {
237+
int countGames = apiResponse.count;
238+
}
161239
```
162240

163-
## Save objects using pins
241+
## Live Queries
242+
This tool allows you to subscribe to a QueryBuilder you are interested in. Once subscribed, the server will notify clients
243+
whenever a ParseObject that matches the QueryBuilder is created or updated, in real-time.
164244

165-
You can now save an object by calling .pin() on an instance of an object
245+
Parse LiveQuery contains two parts, the LiveQuery server and the LiveQuery clients. In order to use live queries, you need
246+
to set up both of them.
166247

248+
The Parse Server configuration guide on the server is found here https://docs.parseplatform.org/parse-server/guide/#live-queries and is not part of this documentation.
249+
250+
Initialize the Parse Live Query by entering the parameter liveQueryUrl in Parse().initialize:
167251
```dart
168-
dietPlan.pin();
252+
Parse().initialize(
253+
ApplicationConstants.keyApplicationId,
254+
ApplicationConstants.keyParseServerUrl,
255+
clientKey: ApplicationConstants.keyParseClientKey,
256+
debug: true,
257+
liveQueryUrl: ApplicationConstants.keyLiveQueryUrl,
258+
autoSendSessionId: true);
169259
```
170260

171-
and to retrieve it
261+
Declare LiveQuery:
262+
```dart
263+
final LiveQuery liveQuery = LiveQuery();
264+
```
172265

266+
Set the QueryBuilder that will be monitored by LiveQuery:
173267
```dart
174-
var dietPlan = DietPlan().fromPin('OBJECT ID OF OBJECT');
268+
QueryBuilder<ParseObject> query =
269+
QueryBuilder<ParseObject>(ParseObject('TestAPI'))
270+
..whereEqualTo('intNumber', 1);
175271
```
272+
__Create a subscription__
273+
You’ll get the LiveQuery events through this subscription.
274+
The first time you call subscribe, we’ll try to open the WebSocket connection to the LiveQuery server for you.
176275

177-
## Increment Counter values in objects
276+
```dart
277+
await liveQuery.subscribe(query);
278+
```
178279

179-
Retrieve it, call
280+
__Event Handling__
281+
We define several types of events you’ll get through a subscription object:
180282

283+
__Create event__
284+
When a new ParseObject is created and it fulfills the QueryBuilder you subscribe, you’ll get this event.
285+
The object is the ParseObject which was created.
181286
```dart
182-
var response = await dietPlan.increment("count", 1);
183-
287+
liveQuery.on(LiveQueryEvent.create, (value) {
288+
print('*** CREATE ***: ${DateTime.now().toString()}\n $value ');
289+
print((value as ParseObject).objectId);
290+
print((value as ParseObject).updatedAt);
291+
print((value as ParseObject).createdAt);
292+
print((value as ParseObject).get('objectId'));
293+
print((value as ParseObject).get('updatedAt'));
294+
print((value as ParseObject).get('createdAt'));
295+
});
184296
```
185297

186-
## Array Operator in objects
298+
__Update event__
299+
When an existing ParseObject which fulfills the QueryBuilder you subscribe is updated (The ParseObject fulfills the
300+
QueryBuilder before and after changes), you’ll get this event.
301+
The object is the ParseObject which was updated. Its content is the latest value of the ParseObject.
302+
```dart
303+
liveQuery.on(LiveQueryEvent.update, (value) {
304+
print('*** UPDATE ***: ${DateTime.now().toString()}\n $value ');
305+
print((value as ParseObject).objectId);
306+
print((value as ParseObject).updatedAt);
307+
print((value as ParseObject).createdAt);
308+
print((value as ParseObject).get('objectId'));
309+
print((value as ParseObject).get('updatedAt'));
310+
print((value as ParseObject).get('createdAt'));
311+
});
312+
```
187313

188-
Retrieve it, call
314+
__Enter event__
315+
When an existing ParseObject’s old value does not fulfill the QueryBuilder but its new value fulfills the QueryBuilder,
316+
you’ll get this event. The object is the ParseObject which enters the QueryBuilder.
317+
Its content is the latest value of the ParseObject.
318+
```dart
319+
liveQuery.on(LiveQueryEvent.enter, (value) {
320+
print('*** ENTER ***: ${DateTime.now().toString()}\n $value ');
321+
print((value as ParseObject).objectId);
322+
print((value as ParseObject).updatedAt);
323+
print((value as ParseObject).createdAt);
324+
print((value as ParseObject).get('objectId'));
325+
print((value as ParseObject).get('updatedAt'));
326+
print((value as ParseObject).get('createdAt'));
327+
});
328+
```
189329

330+
__Leave event__
331+
When an existing ParseObject’s old value fulfills the QueryBuilder but its new value doesn’t fulfill the QueryBuilder,
332+
you’ll get this event. The object is the ParseObject which leaves the QueryBuilder.
333+
Its content is the latest value of the ParseObject.
190334
```dart
191-
var response = await dietPlan.add("listKeywords", ["a", "a","d"]);
335+
liveQuery.on(LiveQueryEvent.leave, (value) {
336+
print('*** LEAVE ***: ${DateTime.now().toString()}\n $value ');
337+
print((value as ParseObject).objectId);
338+
print((value as ParseObject).updatedAt);
339+
print((value as ParseObject).createdAt);
340+
print((value as ParseObject).get('objectId'));
341+
print((value as ParseObject).get('updatedAt'));
342+
print((value as ParseObject).get('createdAt'));
343+
});
344+
```
192345

193-
var response = await dietPlan.addUnique("listKeywords", ["a", "a","d"]);
346+
__Delete event__
347+
When an existing ParseObject which fulfills the QueryBuilder is deleted, you’ll get this event.
348+
The object is the ParseObject which is deleted
349+
```dart
350+
liveQuery.on(LiveQueryEvent.delete, (value) {
351+
print('*** DELETE ***: ${DateTime.now().toString()}\n $value ');
352+
print((value as ParseObject).objectId);
353+
print((value as ParseObject).updatedAt);
354+
print((value as ParseObject).createdAt);
355+
print((value as ParseObject).get('objectId'));
356+
print((value as ParseObject).get('updatedAt'));
357+
print((value as ParseObject).get('createdAt'));
358+
});
359+
```
194360

195-
var response = await dietPlan.remove("listKeywords", ["a"]);
361+
__Unsubscribe__
362+
If you would like to stop receiving events from a QueryBuilder, you can just unsubscribe the subscription.
363+
After that, you won’t get any events from the subscription object and will close the WebSocket connection to the
364+
LiveQuery server.
196365

366+
```dart
367+
await liveQuery.unSubscribe();
197368
```
198369

199-
200370
## Users
201-
202371
You can create and control users just as normal using this SDK.
203372

204373
To register a user, first create one :
@@ -229,7 +398,6 @@ Other user features are:-
229398
* Queries
230399

231400
## Config
232-
233401
The SDK now supports Parse Config. A map of all configs can be grabbed from the server by calling :
234402
```dart
235403
var response = await ParseConfig().getConfigs();
@@ -241,13 +409,8 @@ ParseConfig().addConfig('TestConfig', 'testing');
241409
```
242410

243411
## Other Features of this library
244-
245412
Main:
246-
* Users
247413
* Installation
248-
* Objects
249-
* Queries
250-
* LiveQueries
251414
* GeoPoints
252415
* Files
253416
* Persistent storage
@@ -265,11 +428,13 @@ User:
265428
* Save
266429
* Destroy
267430
* Queries
431+
* Anonymous
432+
* 3rd Party Authentication
268433

269434
Objects:
270435
* Create new object
271436
* Extend Parse Object and create local objects that can be saved and retreived
272-
* Queries:
437+
* Queries
273438

274439
## Author:-
275440
This project was authored by Phill Wiggins. You can contact me at [email protected]

0 commit comments

Comments
 (0)