diff --git a/lib/database.js b/lib/database.js index b2406d0..d075711 100644 --- a/lib/database.js +++ b/lib/database.js @@ -447,7 +447,8 @@ Database.prototype.enforceUniqueness = function(collectionName, values, updatedI if(!attrDef.unique) continue; for (var index in this.data[collectionName]) { - + if (typeof this.data[collectionName][index] === "undefined" || this.data[collectionName][index] === null) continue; + // Ignore uniqueness check on undefined values // (they shouldn't have been stored anyway) if (_.isUndefined(values[attrName])) continue;