Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._updateSimpleProps(model, toCreate, state);
// we link objects by applying patches after we determine that the operation
// will succeed, so we need to create a copy so that we can insert the unlinked
// version into our store and return the linked version to the client
toReturn = clone(toCreate);
[
relationPatches,
willReject,
withReason
] = this._updateLinkProperties(model, toReturn, state, true, 'create');
if (!willReject) {
this._setData(model, toCreate);
jsonpatch.apply(this._data, relationPatches);
} else {
return this._promise.reject(new Error(withReason));
}
}
return this._promise.resolve(toReturn);
}
parser.on('root', function (patches) {
if (!jsonpatch.apply(object, patches)) {
stream.unpipe();
returnErrorAndObject('error applying patches ' + me.stringifyPatches(patches));
}
});
stream.on('error', function (error) {
return this.refreshIfNeeded().then(() => {
const newValues = extend(true, {}, this.values);
patch.apply(newValues, patches);
const affected = this._getAffectedProperties(patches);
const oldKeys = Object.getOwnPropertyNames(this.values);
return Q.all(affected.map(key => {
if (newValues[key] !== undefined) {
return this.set(key, newValues[key]);
}
if (oldKeys.includes(key)) {
return this.delete(key);
}
return Q();
}));
});
}
patch: function patch(prev, next) {
return jsonpatch.apply(prev, next);
},
/**
parser.on('root', function (patches) {
if (!jsonpatch.apply(object, patches)) {
stream.unpipe();
returnErrorAndObject('error applying patches ' + stringifyPatches(patches));
}
});
stream.on('error', function (error) {