Skip to content

Add dot notation key in query examples #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions _includes/android/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ losingUserQuery.findInBackground(new FindCallback<ParseUser>() {
}
});
```
<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>

```java
ParseQuery<ParseObject> chartersOfTypeX = ParseQuery.getQuery("Charter");
charterOfTypeX.equalTo('type', 'x');

ParseQuery<ParseObject> groupsWithoutCharterX = ParseQuery.getQuery("Group");
groupsWithoutCharterX.doesNotMatchKeyInQuery("objectId", "belongsTo.objectId", chartersOfTypeX);
groupsWithoutCharterX.findInBackground(new FindCallback<ParseObject>() {
void done(List<ParseObject> results, ParseException e) {
// results has the list of groups without charter x
});
```

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`):

Expand Down
15 changes: 14 additions & 1 deletion _includes/js/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ alert("Successfully retrieved " + results.length + " scores.");
for (let i = 0; i < results.length; i++) {
var object = results[i];
alert(object.id + ' - ' + object.get('playerName'));
}
}
```

## Query Constraints
Expand Down Expand Up @@ -130,6 +130,19 @@ losingUserQuery.doesNotMatchKeyInQuery("hometown", "city", teamQuery);
const results = await losingUserQuery.find();
```

To filter rows based on `objectId`'s from pointers in a second table, you can use dot notation:

```javascript
const rolesOfTypeX = new Parse.Query('Role');
rolesOfTypeX.equalTo('type', 'x');

const groupsWithRoleX = new Parse.Query('Group');
groupsWithRoleX.matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
groupsWithRoleX.find().then(function(results) {
// results has the list of groups with role x
});
```

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`):

```javascript
Expand Down
12 changes: 12 additions & 0 deletions _includes/php/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ $results = $losingUserQuery->find();

### Select

To filter rows based on `objectId`'s from pointers in a second table, you can use dot notation:

```javascript
$rolesOfTypeX = new ParseQuery('Role');
$rolesOfTypeX->equalTo('type', 'x');

$groupsWithRoleX = new ParseQuery('Group');
$groupsWithRoleX->matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
$results = $groupsWithRoleX->find();
// results has the list of groups with role x
```

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`):

```php
Expand Down