strongloop/loopback — pull request #435 by fabien (2014-08-04 16:38:08+00:00)
Title: Implement Model.nestRemoting

Explicitly enable another level of nesting/accessing relations; limited to a depth of 2 levels.

This should also help with multi-tenancy, by scoping to the first model, and then still have the usual relationships available from that level down. The first model is the entry point.

``` javascript
// Models: Book, Page, Image, Note
Book.hasMany(Page);
Page.hasMany(Note);
Image.belongsTo(Book);

Book.nestRemoting('pages');
Image.nestRemoting('book');

// Urls:
/api/books/2/pages/8/notes
/api/books/2/pages/8/notes/4
...
/api/images/6/book/pages
/api/images/6/book/pages/1
...
```

For this to work, the models and relationships should already be setup.
It would be nice to be able to just do:

``` javascript
Book.hasMany(Page, { options: { nest: true } });
Image.belongsTo(Book, { options: { nest: { ... } });
```
@raymondfeng - I can't seem to get this to work, thoughts? Can this be delayed (to some event) for example?