How to insert long value in mongo using node?

mongodb, node.js

Solution

Use mongodb `Long` class. Something like this.

const Long = require('mongodb').Long;

var sequences = this.db.collection('sequences');
sequences.insert( {
    _id: "TEST_SEQ",
    value: Long.fromInt(1)
}, done);

Take a look here for more details

Mongo-db has default types it gives values, That's why it's inserted as an integer.

Problem

I need to insert Long value for an attribute in mongo. ``` var sequences = this.db.collection('sequences'); sequences.insert( { _id: "TEST_SEQ", value: 1 }, done); ``` But this is inserting value as integer, how to make it Long?

Original source