Skip to content

Commit 784ed8f

Browse files
acinaderTomWFox
authored andcommitted
Add dot notation key in query examples (#488)
* changes to make it build locally. Should be good? * Add example on using dot notation in related query. * fixed formatting issues
1 parent a43fe29 commit 784ed8f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

_includes/android/queries.md

Lines changed: 13 additions & 0 deletions
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

_includes/js/queries.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ alert("Successfully retrieved " + results.length + " scores.");
1818
for (let i = 0; i < results.length; i++) {
1919
var object = results[i];
2020
alert(object.id + ' - ' + object.get('playerName'));
21-
}
21+
}
2222
```
2323

2424
## Query Constraints
@@ -130,6 +130,19 @@ losingUserQuery.doesNotMatchKeyInQuery("hometown", "city", teamQuery);
130130
const results = await losingUserQuery.find();
131131
```
132132

133+
To filter rows based on `objectId`'s from pointers in a second table, you can use dot notation:
134+
135+
```javascript
136+
const rolesOfTypeX = new Parse.Query('Role');
137+
rolesOfTypeX.equalTo('type', 'x');
138+
139+
const groupsWithRoleX = new Parse.Query('Group');
140+
groupsWithRoleX.matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
141+
groupsWithRoleX.find().then(function(results) {
142+
// results has the list of groups with role x
143+
});
144+
```
145+
133146
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`):
134147

135148
```javascript

_includes/php/queries.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ $results = $losingUserQuery->find();
161161

162162
### Select
163163

164+
To filter rows based on `objectId`'s from pointers in a second table, you can use dot notation:
165+
166+
```javascript
167+
$rolesOfTypeX = new ParseQuery('Role');
168+
$rolesOfTypeX->equalTo('type', 'x');
169+
170+
$groupsWithRoleX = new ParseQuery('Group');
171+
$groupsWithRoleX->matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
172+
$results = $groupsWithRoleX->find();
173+
// results has the list of groups with role x
174+
```
175+
164176
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`):
165177

166178
```php

0 commit comments

Comments
 (0)