kiva / backbone.siren

Converts Siren JSON representations into Backbone Models
MIT License
14 stars 3 forks source link

Handling multiple rels #8

Closed gxxcastillo closed 11 years ago

gxxcastillo commented 11 years ago

Calling entity.rel() will only return the first rel in the entities rel array.

Related to issue https://github.com/kiva/backbone.siren/issues/4 : We use .rel() internally for naming a sub-entity.

I don't have any use-cases that uses multiple rels so this works fine for me so far but this behavior will probably need to be revisited at some point.

gxxcastillo commented 11 years ago

Removed the .rel() method as it is relative to the entities relationship to its parent and not to the entity itself. Currently, the only way to get an entities rel (or name) is via the parent's ._entities array:

var parent = new Backbone.Siren.Model(sirenObj);
var parentChildData = parent._entities;

The ._entities array is an array of objects that have the following properties: