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?
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.
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