[#291,bugfix][s]: memory backend transform function now works even when records do not have id - fixes #291.
* Also simplified (and made more efficient) by removing dependency on (not very useful) recline.Data.Transform.mapDocs function * As documented in #291 issue was that an id was required in the docs
This commit is contained in:
@@ -227,12 +227,15 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
||||
};
|
||||
|
||||
this.transform = function(editFunc) {
|
||||
var toUpdate = recline.Data.Transform.mapDocs(this.data, editFunc);
|
||||
// TODO: very inefficient -- could probably just walk the documents and updates in tandem and update
|
||||
_.each(toUpdate.updates, function(record, idx) {
|
||||
self.data[idx] = record;
|
||||
var dfd = $.Deferred();
|
||||
// TODO: should we clone before mapping? Do not see the point atm.
|
||||
self.data = _.map(self.data, editFunc);
|
||||
// now deal with deletes (i.e. nulls)
|
||||
self.data = _.filter(self.data, function(record) {
|
||||
return record != null;
|
||||
});
|
||||
return this.save(toUpdate);
|
||||
dfd.resolve();
|
||||
return dfd.promise();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user