PaulUithol/Backbone-relational — Issue #58: Use foreign keys at model instantiation
Author: Sephi-Chan
Created: 2011-12-28 20:37:46+00:00
State: open

Hello,

I want to discuss a feature for Backbone relational. I think it would be even better with the support of operations on foreign keys. I encountered some problems while developing my webgame (a Risk-like) and I really believe there is use cases for that.

To be concise: it would be great to be able to define the associated models with their foreign key. Example:

``` coffee
users = new Users([
new User(id: 1, name: "Romain", friendIds: [ 2, 3 ])
new User(id: 2, name: "Basile", friendIds: [ 1 ])
new User(id: 3, name: "Cyril", friendIds: [ 2, ])
])
```

Without friendIds, it would be painful to declare the friendships (it must be done in two times).
Thanks to the friendIds collection, it's really simple.

What do you think about that? I would be glad to help you in trying to implement this feature.

Romain