jeudi 21 mai 2015

ember-data: relationship between parent / children

Let assume I have a model A referencing 1 record of type B and 2 records of type C (b and c). Now, type B is also referencing an object of type C

A -> a:B
  -> b:C
  -> c:C

B -> a:C

C -> b:A
  -> a:B

Now, when defining A:

export default DS.Model.extend({
  a: DS.belongsTo('B', {async: true, inverse: 'b'}),
  b: DS.belongsTo('C', {async: true, inverse: 'b'}),
  c: DS.belongsTo('C', {async: true, inverse: 'b'})
});

Now, when defining B:

export default DS.Model.extend({
  a: DS.hasMany('C', {async: true, inverse: 'a'})
});

Now, when defining C:

export default DS.Model.extend({
  b: DS.belongsTo('A'),
  b: DS.belongsTo('C')
});

I am getting an error when instantiating A:

Assertion Failed: You defined the 'trail' relationship on mantrailling@model:C:, but you defined the inverse relationships of type mantrailling@model:A: multiple times. Look at http://ift.tt/1aomJhS for how to explicitly specify inverses




Aucun commentaire:

Enregistrer un commentaire