From 1b266bcf00c9e5c48928403280acbccdffa1b85c Mon Sep 17 00:00:00 2001 From: Amir Jafarian Date: Tue, 9 Aug 2016 14:11:12 -0400 Subject: [PATCH] Return error if connector does not implement * Return error if connector does not implement replaceById * This patch is without globalization Backport loopback-datasource-juggler#1034 --- lib/dao.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/dao.js b/lib/dao.js index 223078ed..ac204e22 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -2633,8 +2633,13 @@ DataAccessObject.replaceById = function(id, data, options, cb) { assert(typeof cb === 'function', 'The cb argument must be a function'); var connector = this.getConnector(); - assert(typeof connector.replaceById === 'function', - 'replaceById() must be implemented by the connector'); + + if (typeof connector.replaceById !== 'function') { + var err = new Error('The connector ' + connector.name + ' does not support ' + + 'replaceById operation. This is not a bug in LoopBack. ' + + 'Please contact the authors of the connector, preferably via GitHub issues.'); + return cb(err); + } var pkName = idName(this); if (!data[pkName]) data[pkName] = id;