Skip to content

v4.0.0-beta.6

Pre-release
Pre-release
Compare
Choose a tag to compare
@nbbeeken nbbeeken released this 01 Jul 17:00
· 282 commits to 3.6 since this release
a4e14ff

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.