Skip to content

Commit 8a0c334

Browse files
RodrigoSMarquesphillwiggins
authored andcommitted
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
1 parent 012539b commit 8a0c334

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,54 @@ The features available are:-
106106
* Ascending
107107
* Descending
108108
* Plenty more!
109+
110+
## Relational queries
111+
If you want to retrieve objects where a field contains an object that matches another query, you can use the
112+
__whereMatchesQuery__ condition.
113+
For example, imagine you vave Post class and a Comment class, where each Comment has a pointer to its parent Post.
114+
You can find comments on posts with images by doing:
115+
116+
```dart
117+
QueryBuilder<ParseObject> queryPost =
118+
QueryBuilder<ParseObject>(ParseObject('Post'))
119+
..whereValueExists('image', true);
120+
121+
QueryBuilder<ParseObject> queryComment =
122+
QueryBuilder<ParseObject>(ParseObject('Comment'))
123+
..whereMatchesQuery('post', queryPost);
124+
125+
var apiResponse = await queryComment.query();
126+
```
127+
128+
If you want to retrieve objects where a field contains an object that does not match another query, you can use the
129+
__whereDoesNotMatchQuery__ condition.
130+
Imagine you have Post class and a Comment class, where each Comment has a pointer to its parent Post.
131+
You can find comments on posts without images by doing:
132+
133+
```dart
134+
QueryBuilder<ParseObject> queryPost =
135+
QueryBuilder<ParseObject>(ParseObject('Post'))
136+
..whereValueExists('image', true);
137+
138+
QueryBuilder<ParseObject> queryComment =
139+
QueryBuilder<ParseObject>(ParseObject('Comment'))
140+
..whereDoesNotMatchQuery('post', queryPost);
141+
142+
var apiResponse = await queryComment.query();
143+
```
144+
145+
## Counting Objects
146+
If you only care about the number of games played by a particular player:
147+
148+
```dart
149+
QueryBuilder<ParseObject> queryPlayers =
150+
QueryBuilder<ParseObject>(ParseObject('GameScore'))
151+
..whereEqualTo('playerName', 'Jonathan Walsh');
152+
var apiResponse = await queryPlayers.count();
153+
if (apiResponse.success && apiResponse.result != null) {
154+
int countGames = apiResponse.count;
155+
}
156+
```
109157

110158
## Objects
111159

0 commit comments

Comments
 (0)