Skip to content

Commit 00f8748

Browse files
committed
Add example on using dot notation in related query.
1 parent f979de7 commit 00f8748

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

_includes/android/queries.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ losingUserQuery.findInBackground(new FindCallback<ParseUser>() {
152152
}
153153
});
154154
```
155+
<p>To filter rows based on <code class="highlighter-rouge">objectId</code>’s from pointers in a second table, you can use dot notation:</p>
156+
157+
```java
158+
ParseQuery<ParseObject> chartersOfTypeX = ParseQuery.getQuery("Charter");
159+
charterOfTypeX.equalTo('type', 'x');
160+
161+
ParseQuery<ParseObject> groupsWithoutCharterX = ParseQuery.getQuery("Group");
162+
groupsWithoutCharterX.doesNotMatchKeyInQuery("objectId", "belongsTo.objectId", chartersOfTypeX);
163+
groupsWithoutCharterX.findInBackground(new FindCallback<ParseObject>() {
164+
void done(List<ParseObject> results, ParseException e) {
165+
// results has the list of groups without charter x
166+
});
167+
```
155168

156169
You can restrict the fields returned by calling `selectKeys` with a collection of keys. To retrieve documents that contain only the `score` and `playerName` fields (and also special built-in fields such as `objectId`, `createdAt`, and `updatedAt`):
157170

@@ -365,7 +378,7 @@ final ParseQuery query = ...
365378
query.fromLocalDatastore().findInBackground().continueWithTask((task) -> {
366379
Exception error = task.getError();
367380
if (error instanceof ParseException && ((ParseException) error).getCode() == ParseException.CACHE_MISS) {
368-
// No results from cache. Let's query the network.
381+
// No results from cache. Let's query the network.
369382
return query.fromNetwork().findInBackground();
370383
}
371384
return task;

_includes/js/queries.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ losingUserQuery.find({
149149
});
150150
</code></pre>
151151

152+
To filter rows based on `objectId`'s from pointers in a second table, you can use dot notation:
153+
154+
<pre><code class="javascript">
155+
const rolesOfTypeX = new Parse.Query('Role');
156+
rolesOfTypeX.equalTo('type', 'x');
157+
158+
const groupsWithRoleX = new Parse.Query('Group');
159+
groupsWithRoleX.matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
160+
groupsWithRoleX.find().then(function(results) {
161+
// results has the list of groups with role x
162+
});
163+
</pre></code>
164+
152165
You can restrict the fields returned by calling `select` with a list of keys. To retrieve documents that contain only the `score` and `playerName` fields (and also special built-in fields such as `objectId`, `createdAt`, and `updatedAt`):
153166

154167
<pre><code class="javascript">

_includes/php/queries.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ $results = $losingUserQuery->find();
139139
// results has the array of users with a hometown team with a losing record
140140
</code></pre>
141141

142+
To filter rows based on `objectId`'s from pointers in a second table, you can use dot notation:
143+
144+
<pre><code class="php">
145+
$rolesOfTypeX = new ParseQuery('Role');
146+
$rolesOfTypeX->equalTo('type', 'x');
147+
148+
$groupsWithRoleX = new ParseQuery('Group');
149+
$groupsWithRoleX->matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
150+
$results = $groupsWithRoleX->find();
151+
// results has the list of groups with role x
152+
</pre></code>
153+
142154
You can restrict the fields returned by calling `select` with an array of keys. To retrieve documents that contain only the `score` and `playerName` fields (and also special built-in fields such as `objectId`, `createdAt`, and `updatedAt`):
143155

144156
<pre><code class="php">

0 commit comments

Comments
 (0)