Merge pull request #1681 from strongloop/fix/replication-perf-on-save

Fix perf of rectification after updateAttributes
This commit is contained in:
Miroslav Bajtoš 2015-09-18 17:05:14 +02:00
commit c87bf9a1da
1 changed files with 6 additions and 2 deletions

View File

@ -1425,8 +1425,12 @@ module.exports = function(registry) {
}; };
function rectifyOnSave(ctx, next) { function rectifyOnSave(ctx, next) {
if (ctx.instance) { var instance = ctx.instance || ctx.currentInstance;
ctx.Model.rectifyChange(ctx.instance.getId(), reportErrorAndNext); var id = instance ? instance.getId() :
getIdFromWhereByModelId(ctx.Model, ctx.where);
if (id) {
ctx.Model.rectifyChange(id, reportErrorAndNext);
} else { } else {
ctx.Model.rectifyAllChanges(reportErrorAndNext); ctx.Model.rectifyAllChanges(reportErrorAndNext);
} }