yarn mongodb 4.0.0-beta.6
v4.0.0-beta.6

latest releases: 6.10.0-dev.20241113.sha.20564f7a, 6.10.0-dev.20241112.sha.48ed47ec, 6.10.0-dev.20241109.sha.ed25d561...
3 years ago

The MongoDB Node.js team is pleased to announce version 4.0.0-beta.6 of the mongodb package!

Release Highlights

This is on the larger side of the beta releases we've done so far we're getting closer to calling this version official.

As a breaking change in this release we now make use of the new MongoDriverError and MongoServerError to clarify where the issue arose from. All of the errors that our driver throws subclass from MongoError so its possible to filter in catch blocks using instanceof. Take a look at this example:

// without calling .connect()
await c.insertOne({ a: 1 })
// Uncaught MongoDriverError: MongoClient must be connected before calling MongoClient.prototype.db
//   at MongoClient.db (lib/mongo_client.js)
await c.insertOne({ _id: /a/ })
// Uncaught MongoServerError: can't use a regex for _id
//   at lib/operations/insert.js {
//     index: 0,
//     code: 2
//   }

Here's the highlights:

  • BSON-EXT support is back! Make sure you use bson-ext v4 with the driver v4.
  • Our typescript got some big upgrades, you should get hinting and completion for filters in .find() and update specifiers in findOneAndUpdate()
  • If you store regular expressions in mongodb from another language where the symbols are not supported in native JS regexes, you can now set the bsonRegExp flag to retrieve them
   await collection.insertOne({ a: new BSONRegExp('(?-i)AA_') })
   await collection.findOne({ a: new BSONRegExp('(?-i)AA_') }, { bsonRegExp: true })
   // { _id: ObjectId,  a: BSONRegExp { pattern: '(?-i)AA_', options: '' } }

⚠ BREAKING CHANGES

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 mongodb release

NewReleases is sending notifications on new releases.