I'm using the mongodb 2.2.33
library under nodejs (x64) and am having trouble incrementing a field:
it('increment-test', function () {
let db = repository.db;
return setup
.then(() => {
return db.collection('product').save({ name: 'product1', amount: 0 });
})
.then(() => {
return db.collection('product').update({},
{ $inc: { "amount": mongo.Long(5000000000000000) } });
})
.then(() => {
return db.collection('product').find({}).toArray();
})
.then((results) => {
assert.equal(results[0].amount, 5000000000000000);//fails
})
});
This test fails; instead of 5000000000000000
you actually get 937459712
How can i get this to work under NodeJS? mongo.Long
appears to be the correct type to use from NodeJS but doesnt work.
In case you were wondering the above test passes when you use another number bigger than Int32
- e.g. 3147483647
The largest number this passes with is 4294967296
which is 2^32 -1