MongoDB differences between NumberLong and simple Integer?

后端 未结 2 1115
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 10:46

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

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 11:42

    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/

提交回复
热议问题