Reputation: 12649
I have problem defining the relationship between my models in order to get cascading property. I would like to MapLineString to be deleted when Trail is deleted or Draw is deleted. But I DO NOT want Trail to be deleted when MapDraw or MapLineString gets deleted.
Relationship between the models is :
Trail can have one Trailer, one Team and one mapDraw
MapDraw can have many MapLineString
MapLineString can belongs to Trail AND/OR MapDraw
Trail = DS.Model.extend({
Trailer: DS.belongsTo('mapLinestring', {async: true, inverse: 'trail'}),
Team: DS.belongsTo('mapLinestring', {async: true, inverse: 'trail'}),
mapDraw: DS.belongsTo('mapDraw', {async: true}),
});
MapDraw = DS.Model.extend({
lineStrings: DS.hasMany('mapLinestring', {async: true}),
trail: DS.belongsTo('mtgTrail')
});
MapLineString = DS.Model.extend({
trail: DS.belongsTo('mtgTrail'),
mapDraw: DS.belongsTo('mapDraw'),
});
Assertion Failed: You defined the 'trail' relationship on mantrailling@model:map-linestring:, but you defined the inverse relationships of type mantrailling@model:mtg-trail: multiple times. Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses
Upvotes: 0
Views: 350
Reputation: 12649
Ok, I found out what the problem was. I have been using Localstorage adapter, which does not work with {async: true}. The records were not persisted on the parent side.
Upvotes: 0
Reputation: 6332
Looking at what youve written at the beginning of the post it sounds like
A should be:
export default DS.Model.extend({
bees: DS.hasMany('B', {async: true, inverse: 'abees'}),
cees: DS.hasMany('C', {async: true}), //doesnt need an inverse as you are getting all the ones that belong to A
});
B should be:
export default DS.Model.extend({
cees: DS.hasMany('C', {async: true, inverse: 'bcees'}),
abees: DS.belongsTo('A')
});
and then in C you have two model properties called the same thing
export default DS.Model.extend({
acees: DS.belongsTo('A'),
bcess: DS.belongsTo('B')
});
Your naming conventions also make it quite confusing. Why not just name the attrs of the models something thats relevant to what they represent?
Upvotes: 0