Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Updated Subscription Documentation #26

Closed
wants to merge 3 commits into from
Closed
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
22 changes: 22 additions & 0 deletions docs/Subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,25 @@ observe: function() {
};
}
```
# Subscribing to Complex Queries
Not all queries can be written in a single line of code. To effectively subscribe a component to a complex Parse query it is recommended that you build them inside the observe method before constructing and returning your map of observations.

```js
observe: function() {
var userQuery = new Parse.Query(Parse.User);
userQuery.equalTo("objectId", id);

var Comments = Parse.Object.extend("Comments");

var commentQuery = new Parse.Query(Comments);
commentQuery.matchesQuery("user_reference", userQuery);
activityQuery.include("comment");
commentQuery.descending("createdAt");

return {
comments: commentQuery
};
}
```

The example above illustrates the need for multiple lines of code being used to create your map of observations. The first query is setup to find a specific user based upon their ```objectId```. The second query is setup to match all of the comments for the user that will be returned in the first query. The result of this relational query is then returned and associated with the name ```comments```.