db.myCollection.update({}, {$set: {"isOpen": 0}}, false, true)
it inserts 0.0000000
i want it to insert just 0
how can i do that
Hello,
db.myCollection.update({}, {$set: {“isOpen”: 0}}, false, true)
By default, the mongo shell treats all numbers as floating point values. you can force it to treat a number as an integer if you modify the update command as such:
db.coll.update({}, {$set: {"isOpen": NumberInt(0)}}, false, true)
It looks like the field name that you used (isOpen) refers to a Boolean value. If that’s the case, you might save some storage space by using a Boolean value instead, as explained in this post: How should I store boolean values in MongoDB?
What version of MongoDB are you using? From version 2.2 onwards, positional Boolean parameters in the update() are deprecated. Current versions replaced the positional parameters with an update options document instead.
Best regards,
Kevin