Fix id copmarison by using strings

This commit is contained in:
Laurent Villeneuve 2015-08-17 10:09:44 -04:00
parent f5270c39c5
commit 9363354e0f
1 changed files with 2 additions and 2 deletions

View File

@ -2268,7 +2268,7 @@ RelationDefinition.embedsMany = function embedsMany(modelFrom, modelTo, params)
if (!params.polymorphic) {
modelFrom.validate(propertyName, function(err) {
var embeddedList = this[propertyName] || [];
var ids = embeddedList.map(function(m) { return m[idName]; });
var ids = embeddedList.map(function(m) { return m[idName].toString(); }); // mongodb
var uniqueIds = ids.filter(function(id, pos) {
return ids.indexOf(id) === pos;
});
@ -2869,7 +2869,7 @@ RelationDefinition.referencesMany = function referencesMany(modelFrom, modelTo,
});
modelFrom.validate(relationName, function(err) {
var ids = this[fk] || [];
var ids = (this[fk] || []).map(function (id) {return id.toString(); }); // mongodb
var uniqueIds = ids.filter(function(id, pos) {
return ids.indexOf(id) === pos;
});