TTL indexes ignore documents where indexed field not a date

pull/2/head
Louis Chatriot 9 years ago
parent c4ef652200
commit 362e5d4d15
  1. 30
      test/db.test.js

@ -598,6 +598,36 @@ describe('Database', function () {
}); });
}); });
it("Document where indexed field is absent or not a date are ignored", function (done) {
d.ensureIndex({ fieldName: 'exp', expireAfterSeconds: 0.2 }, function () {
d.insert({ hello: 'world1', exp: new Date() }, function () {
d.insert({ hello: 'world2', exp: "not a date" }, function () {
d.insert({ hello: 'world3' }, function () {
setTimeout(function () {
d.find({}, function (err, docs) {
assert.isNull(err);
docs.length.should.equal(3);
setTimeout(function () {
d.find({}, function (err, docs) {
assert.isNull(err);
docs.length.should.equal(2);
docs[0].hello.should.not.equal('world1');
docs[1].hello.should.not.equal('world1');
done();
});
}, 101);
});
}, 100);
});
});
});
});
});
}); // ==== End of '#getCandidates' ==== // }); // ==== End of '#getCandidates' ==== //

Loading…
Cancel
Save