geddy/model — pull request #184 by ben-ng (2014-04-12 09:57:08+00:00)
Title: Eager loading of nested associations

Not ready for merge yet. First cut at this feature.

```js
// Existing syntax:
model.Thing.all({}, {includes: 'assoc1'}, function (err, data) {});
// Equiv to:
model.Thing.all({}, {includes: ['assoc1']}, function (err, data) {});
// Multiple assocs:
model.Thing.all({}, {includes: ['assoc1', 'assoc2']}, function (err, data) {});

// Nested assocs:
model.Thing.all({}, {includes: {assoc1: 'assoc2'}}, function (err, data) {});
// Equiv to:
model.Thing.all({}, {includes: {assoc1: ['assoc2']}}, function (err, data) {});
// Further nesting:
model.Thing.all({}, {includes: {assoc1: {assoc2: 'assoc3'}}}, function (err, data) {});
// Equiv to:
model.Thing.all({}, {includes: {assoc1: {assoc2: ['assoc3']}}}, function (err, data) {});
// Go nuts:
model.Thing.all({}, {includes: {assoc1: {assoc2: ['assoc2.1', 'assoc2.2']}}}, function (err, data) {});
```

Breaking change: ordering on associations must be done by association name, not table name. Otherwise you'd get conflicts if loading two associations from the same table.

```js
// old behavior:
model.Event.all({}, {includes: 'participants', sort: {'people.id': 'desc'}}, function (err, data) {});
// this would conflict if eager loading two assocs that lead to the `people` table:
model.Event.all({}, {includes: ['participants', 'admins'], sort: {'people.id': 'desc'}}, function (err, data) {});

// new behavior:
model.Event.all({}, {includes: 'participants', sort: {'participants.id': 'desc'}}, function (err, data) {});
```

todo: querying on associations.