Skip to content

Commit

Permalink
Adding documentation for eager-loading SQL associations.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Postlethwait committed Feb 13, 2014
1 parent 1757005 commit e4ff060
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/reference/models.md
Expand Up @@ -490,7 +490,8 @@ Use the `all` method to find lots of items. Pass it a set of query parameters in
- `query [object]`: if the query is an object, it will be interpreted as a Query object - `query [object]`: if the query is an object, it will be interpreted as a Query object


##### options ##### options
- `sort [object]`: each key is a property name, each value can either be `asc` or `desc` - `sort [object]`: each key is a property name, each value can either be `asc` or `desc`.
- `includes [array]`: Using SQL adapters, you may supply an array of model association names to eager-load.


##### example ##### example
``` ```
Expand All @@ -502,6 +503,11 @@ User.all({location: 'san francisco'}, function (err, users) {
User.all({location: 'san francisco'}, {sort: {createdAt: 'desc'}}, function (err, users) { User.all({location: 'san francisco'}, {sort: {createdAt: 'desc'}}, function (err, users) {
// do stuff with users // do stuff with users
}); });
// Eager-load associations of this model. (Only works on SQL adapters.)
User.all({location: 'san francisco'}, {includes: ['posts']}, function (err, users) {
// do stuff with users - each "user" will have a "posts" property eager-loaded from the DB
});
``` ```


* * * * * *
Expand Down

0 comments on commit e4ff060

Please sign in to comment.