From 327c78534709b47a65ce0fc20b8289b1326b1239 Mon Sep 17 00:00:00 2001 From: Amir Jafarian Date: Mon, 8 Aug 2016 11:39:59 -0400 Subject: [PATCH] Return error if the connector does not implement * Return error if the connector does not implement `replaceById` --- lib/dao.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/dao.js b/lib/dao.js index b4bc4dd8..e9c62dac 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -2638,8 +2638,14 @@ 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(g.f( + 'The connector %s does not support {{replaceById}} operation. This is not a bug in LoopBack. ' + + 'Please contact the authors of the connector, preferably via GitHub issues.', + connector.name)); + return cb(err); + } var pkName = idName(this); if (!data[pkName]) data[pkName] = id;