Skip to content

v5.1.0

Compare
Choose a tag to compare
@W-A-James W-A-James released this 23 Feb 18:58
· 372 commits to main since this release
687f51a

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.