Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inverse relationships #36

Open
jamesarosen opened this issue Mar 24, 2012 · 0 comments
Open

Support inverse relationships #36

jamesarosen opened this issue Mar 24, 2012 · 0 comments

Comments

@jamesarosen
Copy link
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant