MyGit

v4.6.0

mongodb/node-mongodb-native

版本发布时间: 2022-05-12 03:27:36

mongodb/node-mongodb-native最新发布版本:v6.9.0(2024-09-13 01:12:41)

The MongoDB Node.js team is pleased to announce version 4.6.0 of the mongodb package!

Release Highlights

TypeScript: ChangeStreamDocument

Our change stream document type and watch API have undergone some improvements! You can now define your own custom type for the top level document returned in a 'change' event. This is very useful when using a pipeline that significantly changes the shape of the change document (ex. $replaceRoot, $project operators). Additionally, we've improved the type information of the default change stream document to default to union of the possible events from MongoDB. This works well with typescript's ability to narrow a Discriminated Union based on the operationType key in the default change stream document.

Prior to this change the ChangeStreamDocument inaccurately reflected the runtime shape of the change document. Now, using the union, we correctly indicate that some properties do not exist at all on certain events (as opposed to being optional). With this typescript fix we have added the properties to for rename events, as well as lsid, txnNumber, and clusterTime if the change is from within a transaction.

NOTE: Updating to this version may require fixing typescript issues. Those looking to adopt this version but defer any type corrections can use the watch API like so: .watch<any, X>(). Where X controls the type of the change document for your use case.

Check out the examples and documentation here.

Performance: Consider Server Load During Server Selection

Operations will now be directed towards servers that have fewer in progress operations. This distributes load across servers and prevents overwhelming servers that are already under load with additional requests.

Note

This release includes some experimental features that are not yet ready for use. As a reminder, anything marked experimental is not a part of the official driver API and is subject to change without notice.

Features

Bug Fixes

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

相关地址:原始地址 下载(tar) 下载(zip)

查看:2022-05-12发行的版本