v4.0.0-beta.4
Pre-releaseThe MongoDB Node.js team is pleased to announce version 4.0.0.beta.4 of the driver.
Release Highlights
This beta release brings optional support for Typescript generics when defining your collections
// Example:
interface Pet {
type: 'cat' | 'dog' | 'fish'
}
const collection = db.collection<Pet>()
await collection.findOne({}).toArray() // returns Pet[]as well as strong typing for events emitted by the MongoClient. For example, when listening to .on('commandStarted' event => ...), event here will be a CommandStartedEvent object.
We have a few breaking changes listed below, notably the node driver now aligns with other drivers by using the returnDocument option when determining whether to return the document before or after the update in findOneAndUpdate and findOneAndReplace.
⚠ BREAKING CHANGES
- NODE-1812: replace returnOriginal with returnDocument option (#2803)
- NODE-3157: update find and modify interfaces for 4.0 (#2799)
- NODE-2978: remove deprecated bulk ops (#2794)
Features
- NODE-3115: Add generic parameterization (#2767) (4d12491)
- NODE-3132: Add TypedEventEmitter (#2785) (f4d40a4)
Bug Fixes
-
NODE-2995: Add shared metadata MongoClient (#2772) (9073d54)
-
NODE-3074: update estimated document count for v1 api (#2764) (146791c)
-
NODE-3109: prevent servername from being an IP (#2771) (27089be)
-
NODE-3166: allowInvalidHostnames and allowInvalidCertificates flags are ignored (#2784) (a769cf8)
-
NODE-3174: Preserve sort key order for numeric string keys (#2788) (440de41)
-
NODE-3176: handle errors from MessageStream (#2780) (76b110e)
-
NODE-3194: Ignore undefined and null options in MongoClient constructor (#2800) (8bb92f9)
-
NODE-3197: revert setImmediate in waitQueue (#2802) (6c0dfef)
-
NODE-3206: Make distinct use any[] type instead of Document[] (#2795) (b45e3b3)
-
NODE-3219: topology no longer causes close event (#2792) (6cd982f)
-
NODE-1812: replace returnOriginal with returnDocument option (#2803) (1cdc8a8)
-
NODE-3157: update find and modify interfaces for 4.0 (#2799) (29512da)
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 driver immediately, and report any issues to the NODE project.
To try the beta use the following command:
npm install [email protected]Thanks very much to all the community members who contributed to this release!