How to use the Long function from mongodb

Find comprehensive JavaScript mongodb.Long code examples handpicked from public code repositorys.

28
29
30
31
32
33
34
35
36

```javascript
const { Int32, Long } = require('mongodb');

const myInt32 = new Int32(42); // Creates a 32-bit integer
const myInt64 = new Long(9007199254740991); // Creates a 64-bit integer
```

Remember that choosing the appropriate integer size can help optimize storage and performance within your MongoDB application. Use `Int32` for smaller value ranges and `Int64` for larger value ranges as needed.
fork icon428
star icon0
watch icon84

+ 15 other calls in file

29
30
31
32
33
34
35
36
37
38
module.exports.Binary = mongodb.Binary
module.exports.Code = mongodb.Code
module.exports.DBRef = mongodb.DBRef
module.exports.Double = mongodb.Double
module.exports.Int32 = mongodb.Int32
module.exports.Long = mongodb.Long
module.exports.MaxKey = mongodb.MaxKey
module.exports.MinKey = mongodb.MinKey
module.exports.NumberLong = mongodb.Long // Alias for shell compatibility
module.exports.ObjectId = mongodb.ObjectId
fork icon272
star icon0
watch icon59

+ 15 other calls in file

365
366
367
368
369
370
371
372
373
374
  done();
});

it('untransforms mongodb number types', done => {
  const input = {
    long: mongodb.Long.fromNumber(Number.MAX_SAFE_INTEGER),
    double: new mongodb.Double(Number.MAX_VALUE),
  };
  const output = transform.mongoObjectToParseObject(null, input, {
    fields: {
fork icon0
star icon0
watch icon1