diff --git a/lib/datastore.js b/lib/datastore.js index 7ca8226..0c52534 100644 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -341,7 +341,7 @@ Datastore.prototype._insertMultipleDocsInCache = function (newDocs) { var i, failingI, error , preparedDocs = this.prepareDocumentForInsertion(newDocs) ; - + for (i = 0; i < preparedDocs.length; i += 1) { try { this.addToIndexes(preparedDocs[i]); diff --git a/test/.db.test.js.swo b/test/.db.test.js.swo new file mode 100644 index 0000000..fb62a53 Binary files /dev/null and b/test/.db.test.js.swo differ diff --git a/test/db.test.js b/test/db.test.js index a02bf3d..4ae60e4 100644 --- a/test/db.test.js +++ b/test/db.test.js @@ -257,8 +257,11 @@ describe('Database', function () { err.errorType.should.equal('uniqueViolated'); d.find({}, function (err, docs) { + // Datafile only contains index definition + var datafileContents = model.deserialize(fs.readFileSync(testDb, 'utf8')); + assert.deepEqual(datafileContents, { $$indexCreated: { fieldName: 'a', unique: true } }); + docs.length.should.equal(0); - fs.readFileSync(testDb, 'utf8').length.should.equal(0); // Datafile not written to done(); });