Merge pull request #1034 from strongloop/err_connector_not_implements_replaceById
Return error if the connector does not implement
This commit is contained in:
commit
1e57d4f316
10
lib/dao.js
10
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;
|
||||
|
|
Loading…
Reference in New Issue