github mongodb/node-mongodb-native v4.0.0-beta.6

latest releases: v6.5.0, v6.4.0, v5.9.2...
pre-release2 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 node-mongodb-native release

NewReleases is sending notifications on new releases.