Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Updates populate documentation #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 18 additions & 2 deletions queries/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ User.find()
`populate` is used with associations to include any related values specified in a model definition.
If a `collection` attribute is defined in a many-to-many, one-to-many or many-to-many-through
association the `populate` option also accepts a full criteria object. This allows you
to filter associations and run `limit` and `skip` on the results.
to filter associations and run `limit` and `skip` on the results. Attribute Name can be a string with the name of the association, or a string array of association names.
> string array of association names is available since version v.0.10.29

| Description | Accepted Data Types | Required ? |
|---------------------|---------------------|------------|
| Attribute Name | `string` | Yes |
| Attribute Name | `string|array of strings` | Yes |
| Criteria Object | `{}` | No |

```javascript
Expand All @@ -94,6 +95,21 @@ User.find()
.exec(function(err, users) {});
```

```javascript
// Populating more than one relation
User.find()
.populate('foo')
.populate('bar')
.exec(function(err, users) {});
```

```javascript
// Populating more than one relation (alternative syntax)
User.find()
.populate(['foo', 'bar'])
.exec(function(err, users) {});
```

```javascript
// Collection Filtering
User.find()
Expand Down