diff --git a/lib/Drivers/DML/mongodb.js b/lib/Drivers/DML/mongodb.js index 9579362d..9f44f1cd 100644 --- a/lib/Drivers/DML/mongodb.js +++ b/lib/Drivers/DML/mongodb.js @@ -45,6 +45,13 @@ Driver.prototype.sync = function (opts, cb) { } pending = indexes.length; + + collection.dropIndexes(); + for (var i = 0; i < opts.id.length; i++) { + var obj = {}; + obj[opts.id[i]] = 1; + collection.createIndex(obj, {unique: true}); + } for (i = 0; i < indexes.length; i++) { collection.createIndex(indexes[i], function () {