I would like to save int32
or int64
values from my Atlas Trigger (NodeJS code), but when i save any value it saves it as a Double
.
user_collection.updateOne({"_id": "anyID"}, {$inc: {"score": 2}});
With the above line, score
is a type of Double
in the database.
I would like to have it as int64
.
How can i force the use of int64
(or int32
) in that case please ?
2
Answers
From documentation:
So it is really confusing. You may prefer the Long methods if you like to modify the value.
Note,
mongosh
is also a Node.js terminal.You can just use :
user_collection.updateOne({"_id": "anyID"}, {$inc: {"score": parseInt(2, 10)}});
And it will save an Int32 in your database.