github mongodb/node-mongodb-native v5.1.0

latest releases: v6.9.0, v6.8.2, v6.8.1...
19 months ago

The MongoDB Node.js team is pleased to announce version 5.1.0 of the mongodb package!

Release Highlights

Support for JavaScript bigints in the driver

The driver now supports automatic serialization of JavaScript bigints to BSON.Longs. It also supports deserializing of BSON.Long values returned from the server to bigint values when the useBigInt64 flag is passed as true.

import { MongoClient } from 'mongodb';

(async () => {
  const client = new MongoClient('<YOUR CONNECTION STRING>');
  const db = client.db('test');
  const coll = db.collection('bigints');

  await coll.insertOne({ a: 10n }); // The driver automatically serializes bigints to BSON.Long before being sent to the server

  const docBigInt = await coll.findOne({ a: 10n }, { useBigInt64: true }); // Must provide the useBigInt64 flag to specify that bigints get returned
  console.log(docBigInt);
  // { _id: ObjectId(...), a: 10n }
  const doc = await coll.findOne({ a: 10n }); // Must provide the useBigInt64 flag to specify that bigints get returned
  console.log(doc);
  // { _id: ObjectId(...), a: 10 }
  await client.close();
})()

Features

Bug Fixes

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

Don't miss a new node-mongodb-native release

NewReleases is sending notifications on new releases.