In nested hasOne and hasMany associations, it's useful to have the associated objects have pointers back to the origin object. This can't be done by overriding init since the object won't have been fetched and thus the associated objects may not exist. It can't be done by overriding the association method and calling _super because the association is defined first in this class, not a parent.
I suggest the following:
Owner = Ember.Resource.define({
foo: {
type: 'Foo',
nested: true,
inverse: 'owner'
},
bars: {
type: Ember.ResourceCollection,
itemType: 'Bar',
nested: true,
inverse: 'owner'
}
});
This would declare owner properties on the associated Foos and Bars. For example
someOwner.getPath('foo.owner') === someOwner; // true
In nested
hasOneandhasManyassociations, it's useful to have the associated objects have pointers back to the origin object. This can't be done by overridinginitsince the object won't have been fetched and thus the associated objects may not exist. It can't be done by overriding the association method and calling_superbecause the association is defined first in this class, not a parent.I suggest the following:
This would declare
ownerproperties on the associatedFoos andBars. For example