Fixed ReferencesMany .findById to check the given id in the ids array of the model instance
This commit is contained in:
parent
0381f6d7e7
commit
ad83c82ebc
|
@ -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