-
-
Save hjdivad/d0c484a56032cd6f511f2b31eabdeb40 to your computer and use it in GitHub Desktop.
hasMany not cleared by pushPayload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.JSONAPIAdapter.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddles', | |
thingIds: Ember.computed.mapBy('model.things', 'id'), | |
thingState: Ember.computed.mapBy('model.things', 'isDeleted') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
things: hasMany('thing') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
person: belongsTo('person') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
beforeModel() { | |
let data = { | |
data: { | |
id: 1, | |
type: 'person', | |
relationships: { | |
things: { | |
data: [ | |
{id: 1, type: 'thing'}, | |
{id: 2, type: 'thing'}, | |
] | |
} | |
} | |
}, | |
included: [ | |
{id: 1, type: "thing"}, | |
{id: 2, type: "thing"} | |
] | |
}; | |
this.store.pushPayload(data); | |
}, | |
model() { | |
let person = this.store.peekRecord('person', 1); | |
let things = this.store.peekAll('thing'); | |
let [thing] = things.toArray(); | |
// set 2 thing on the person | |
//person.set('things', things); | |
// or this also shows same behaviour | |
// person.get('things').pushObject(thing); | |
let data = { | |
id: 1, | |
type: 'person', | |
relationships: { | |
things: { | |
data: [] | |
} | |
} | |
}; | |
// this should clear the things from the person | |
this.store.pushPayload({data}); | |
return person; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.11.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js", | |
"ember": "2.10.2", | |
"ember-data": "release", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment