Does MongoDB Map / Reduce save results in floats?

I am using Mongoid, which is on top of the Ruby MongDB driver. Despite the fact that my Map issuer allocates parseInt(num), and Return also returns a value parseInt(num), the final results are still floats.

Is this especially important for MongoDB? Any way to make it an integer?

+3
source share
1 answer

The function parseIntofficially accepts the string as a parameter. This string is parsed as if it were an integer, ignoring everything after the first non-numeric character. If you specify a floating point number, it will be converted to a string before parsing it.

parseInt Number, . Number - JavaScript; .

, parseInt , . Mongoid , float . , .

Update

NumberLong, 64- . new NumberLong(num) , Mongoid .

, MongoDB 1.6 , Shell MongoDB. , .

+5

Source: https://habr.com/ru/post/1765213/


All Articles