v4.0.0-beta.6
Pre-release
Pre-release
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 infindOneAndUpdate()
- 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
- NODE-3291: Standardize error representation in the driver (#2824)
- NODE-3272: emit correct event type when SRV Polling (#2825)
- NODE-2752: remove strict/callback mode from Db.collection helper (#2817)
Features
- NODE-2751: add arrayFilters builder to bulk FindOperators (#2820) (d099622)
- NODE-3274: add type hinting for UpdateFilter (#2842) (05035eb)
- NODE-3325: support 'let' option for aggregate command (#2828) (e38838e)
- NODE-3331: offer downleveled types for legacy typescript versions (#2859) (27cf1d2)
- NODE-3333: support 'let' option for CRUD commands (#2829) (0d91da1)
Bug Fixes
- NODE-1502: command monitoring objects hold internal state references (#2832) (a2887db)
- NODE-2026: SERVICE_REALM kerberos mechanism property not attached (#2865) (5caa354)
- NODE-2035: exceptions thrown from awaited cursor forEach do not propagate (#2835) (ac49df6)
- NODE-2905: support SERVICE_NAME authentication mechanism property (#2857) (dfb91b8)
- NODE-2944: Reintroduce bson-ext support (#2823) (8eb0081)
- NODE-3150: allow retrieving PCRE-style RegExp (ca9e2dc)
- NODE-3272: emit correct event type when SRV Polling (#2825) (579119f)
- NODE-3305: beforeHandshake flag is always true (#2854) (079bd6c)
- NODE-3311: InsertOneOptions extends CommandOperationOptions (#2816) (734b481)
- NODE-3335: do not validate explain verbosity in client (#2834) (1a57ba8)
- NODE-3343: allow overriding result document after projection applied (#2856) (988f9c8)
- NODE-3356: update redaction logic for command monitoring events (#2849) (536e5ff)
- NODE-3291: Standardize error representation in the driver (#2824) (9608c6a)
- NODE-2752: remove strict/callback mode from Db.collection helper (#2817) (53abfe7)
Documentation
- Reference: https://docs.mongodb.com/drivers/node
- API: https://mongodb.github.io/node-mongodb-native/4.0
- Changelog: https://github.com/mongodb/node-mongodb-native/blob/4.0/HISTORY.md
We invite you to try the mongodb library immediately, and report any issues to the NODE project.