Permalink
Browse files

Adding documentation for eager-loading SQL associations.

  • Loading branch information...
1 parent 1757005 commit e4ff060ca73c73f1ae72bb65dae1c14b33a243bc @JohnPostlethwait JohnPostlethwait committed Feb 12, 2014
Showing with 7 additions and 1 deletion.
  1. +7 −1 docs/reference/models.md
View
@@ -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 e4ff060

Please sign in to comment.