Can now have an _id which is 0

pull/2/head
Louis Chatriot 10 years ago
parent 8de7d0c39d
commit bfca0c4799
  1. 4
      lib/datastore.js
  2. 8
      test/db.test.js

@ -312,7 +312,9 @@ Datastore.prototype.prepareDocumentForInsertion = function (newDoc) {
preparedDoc = [];
newDoc.forEach(function (doc) { preparedDoc.push(self.prepareDocumentForInsertion(doc)); });
} else {
newDoc._id = newDoc._id || this.createNewId();
if (newDoc._id === undefined) {
newDoc._id = this.createNewId();
}
preparedDoc = model.deepCopy(newDoc);
model.checkObject(preparedDoc);
}

@ -267,6 +267,14 @@ describe('Database', function () {
});
});
});
it('Can insert a doc with id 0', function (done) {
d.insert({ _id: 0, hello: 'world' }, function (err, doc) {
doc._id.should.equal(0);
doc.hello.should.equal('world');
done();
});
});
/**
* Complicated behavior here. Basically we need to test that when a user function throws an exception, it is not caught

Loading…
Cancel
Save