What are the main differences (size, speed, etc) between the datatypes double, NumberLong, NumberInt or a simple Integer in MongoDB?
If I want to save a small fixed number (something between 0 and 1000) which data type should I use?
NumberLong. The mongo shell treats all numbers as floating-point values by default. The mongo shell provides the NumberLong() wrapper to handle 64-bit integers. The NumberLong() wrapper accepts the long as a string: NumberLong("2090845886852")
ISODate() is a helper function that's built into to MongoDB and wraps the native JavaScript Date object. When you use the ISODate() constructor from the Mongo shell, it actually returns a JavaScript Date object.
NumberInt
By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberInt()
constructor to explicitly specify 32-bit integers.
NumberLong
By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberLong()
class to handle 64-bit integers.
The NumberLong()
constructor accepts the long as a string:
NumberLong("2090845886852")
Source: http://docs.mongodb.org/manual/core/shell-types/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With