Search code examples
javascriptmongodbtypesint32

Is it possible to define an int32 value in javascript console?


Do I understand right that it is impossible to define and store an int32 value in the mongodb javascript console? So if I want to do so a have no choice but to write a program in Java or other language with well-typed driver interface?

The only more or less clear explanation I could find is BUG #854 in mongodb's JIRA. But I just can't believe that such a simple and vital feature is avoided.


Solution

  • It's even worse than that, if you retrieve data in the JS console and then write it back to the DB, it will convert interegers to floats.

    AFAIK the new feature to fix this is still not implemented. The new feature was implemented in 1.9.1:

    var intValue = NumberInt(3);