dhruvaray/backbone-associations — pull request #12 by kusch (2012-10-29 08:30:53+00:00)
Title: reverse option

Issue #10

May be it will be useful for somebody.
Now we can automatically create association models(collections) with reference to parent like this
```javascript
TuneModel = Backbone.AssociatedModel.extend();

UserModel = Backbone.AssociatedModel.extend({
defaults: {
tunes: [],
name: "username"
},
relations: [
{
type: Backbone.Many,
key: "tunes",
relatedModel: TuneModel,
// collectionType: TuneCollection,
reverse: true
},
{
type: Backbone.One,
key: "tune_one",
relatedModel: TuneModel,
reverse: true
}
]
});

user = new UserModel();
user.get("tunes").add({
title: "title",
artist: "artist"
});

user.set("tune_one",{
title: "title",
artist: "artist"
});
console.log(user)​
```

http://jsfiddle.net/sergkusch/em26w/3/