By default, the MongoDB shell interprets all numbers as floats; this is a problem when trying to convert existing JSON formatted data (stored as strings in Mongo) to actual Mongo BSON objects. It would also be tedious to explicitly and manually wrap any integer values in the data with NumberInt(...)
/NumberLong(...)
because integers can occur anywhere in the data.
Is there a way to configure one MongoDB shell session to use NumberInt
or NumberLong
by default?
Alternatively: is there a way to parse a string of JSON into an object in the MongoDB shell so that all numbers without decimal points are already wrapped with NumberInt
/NumberLong
?