Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
didSaveRecord: function (record, data) {
if (data) {
this.didSaveRecordForHasManyItems(this, record.constructor, data, record);
this._super(record, data);
// Fixes introdution in ember-data.1.0.0.beta4 (see method "addUnsavedRecords" in Store)
// assume that "any unsaved records that are
// in a hasMany they won't be in the payload"
// which could be not true if serializer handles child items
didSaveRecordForHasManyItems: function (store, type, data, record) {
var self = this;
type.eachRelationship(function (key, relationship) {
var kind = relationship.kind,
value = data[key];
if (value === null) { return; }
if (kind === 'hasMany') {
record.get(key).forEach(function (childRecord) {
self.didSaveRecordForHasManyItems(store, childRecord.constructor, {}, childRecord);
return data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.