Merge pull request #699 from satyadeepk/master
Fixed ReferencesMany .findById to check the given id in the modelInstance[fk]
This commit is contained in:
commit
febfe2362a
|
@ -2985,7 +2985,7 @@ ReferencesMany.prototype.findById = function (fkId, options, cb) {
|
||||||
fkId = fkId.toString(); // mongodb
|
fkId = fkId.toString(); // mongodb
|
||||||
}
|
}
|
||||||
|
|
||||||
var ids = [fkId];
|
var ids = modelInstance[fk] || [];
|
||||||
|
|
||||||
var filter = {};
|
var filter = {};
|
||||||
|
|
||||||
|
@ -2993,7 +2993,7 @@ ReferencesMany.prototype.findById = function (fkId, options, cb) {
|
||||||
|
|
||||||
cb = cb || utils.createPromiseCallback();
|
cb = cb || utils.createPromiseCallback();
|
||||||
|
|
||||||
modelTo.findByIds(ids, filter, options, function (err, instances) {
|
modelTo.findByIds([fkId], filter, options, function (err, instances) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue