From 0bac0a933f850001f4c9531587870a2265c73363 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Tue, 5 Dec 2017 09:49:50 -0600 Subject: [PATCH] fix(id): replace with != null Ref: #2356, #2374, #3130, #3693 --- lib/model.js | 4 ++-- lib/persisted-model.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/model.js b/lib/model.js index 1cc87781..ca49a22e 100644 --- a/lib/model.js +++ b/lib/model.js @@ -161,13 +161,13 @@ module.exports = function(registry) { } } - if (id && data) { + if (id != null && data) { var model = new ModelCtor(data); model.id = id; fn(null, model); } else if (data) { fn(null, new ModelCtor(data)); - } else if (id) { + } else if (id != null) { var filter = {}; ModelCtor.findById(id, filter, options, function(err, model) { if (err) { diff --git a/lib/persisted-model.js b/lib/persisted-model.js index 10ff0591..8bfb4b67 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -1710,7 +1710,7 @@ module.exports = function(registry) { ctx.instance, ctx.currentInstance, ctx.where, ctx.data); } - if (id) { + if (id != null) { ctx.Model.rectifyChange(id, reportErrorAndNext); } else { ctx.Model.rectifyAllChanges(reportErrorAndNext); @@ -1734,7 +1734,7 @@ module.exports = function(registry) { debug('context instance:%j where:%j', ctx.instance, ctx.where); } - if (id) { + if (id != null) { ctx.Model.rectifyChange(id, reportErrorAndNext); } else { ctx.Model.rectifyAllChanges(reportErrorAndNext);