Permalink
Browse files

Merge pull request #547 from JohnPostlethwait/master

Adding documentation for eager-loading SQL associations.
  • Loading branch information...
2 parents 1757005 + e4ff060 commit 2c205f63bdbd54c03a44a62c5db66ace7ee23e8a @mde mde committed Feb 13, 2014
Showing with 7 additions and 1 deletion.
  1. +7 −1 docs/reference/models.md
View
8 docs/reference/models.md
@@ -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
##### 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
```
@@ -502,6 +503,11 @@ User.all({location: 'san francisco'}, function (err, users) {
User.all({location: 'san francisco'}, {sort: {createdAt: 'desc'}}, function (err, 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
+});
```
* * *

0 comments on commit 2c205f6

Please sign in to comment.