vendredi 21 août 2015

EmberJS multiple inverses of the same model type

I have two data model

// users
export default DS.Model.extend({
    email: DS.attr(),
    workspaces: DS.hasMany('workspace', { async: true })
});

// workspaces
export default DS.Model.extend({
  title: DS.attr('string'),
  owner: DS.belongsTo('user'),
  contributors: DS.hasMany('user'),
});

I expect this logic:

1) user.workspaces contains all workspaces that is owns + all can contribute to.

2) workspace.contributors => should get all contributors

3) workspace.owner => should get single owner.

Ember wouldn't work as it is defined currently and requires explicit inverse which I'm struggling to do.




Aucun commentaire:

Enregistrer un commentaire