Skip to content

Releases: mongodb/node-mongodb-native

v5.0.0-alpha.0

24 Jan 01:17
4fcae82
Compare
Choose a tag to compare
v5.0.0-alpha.0 Pre-release
Pre-release

🚧 Testing Build Only

This alpha build is intended for internal testing only. Adopt at your own risk.

Changes listed in HISTORY.md.

5.0.0-alpha.0 diff v4.13.0 (2023-01-23)

v4.13.0

19 Dec 15:41
eb5f651
Compare
Choose a tag to compare

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

Features

Bug Fixes

Documentation

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

v4.12.1

23 Nov 18:52
73e92ce
Compare
Choose a tag to compare

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

Release Highlights

This version includes a fix to a regression in our monitoring logic that could cause process crashing errors that was introduced in v4.12.0.

If you are using v4.12.0 of the Node driver, we strongly encourage you to upgrade.

Bug Fixes

Documentation

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

4.12.0

16 Nov 20:45
8254575
Compare
Choose a tag to compare

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

Release Highlights

ChangeStreams are now AsyncIterators

ChangeStreams are now async iterables and can be used anywhere that expects an async iterable. Notably, change streams can now be used in Javascript for-await loops:

const changeStream = collection.watch();
for await (const change of changeStream) {
  console.log(“Received change: , change);
}

Some users may have been using change streams in for-await loops manually by using a for-await loop with the ChangeStream’s internal cursor. For example:

const changeStream = collection.watch();
for await (const change of changeStream.cursor) {
  console.log(“Received change: , change);
}

The change stream cursor has no support for resumabilty and consequently the change stream will never attempt to resume on any errors. We strongly caution against using a change stream cursor as an async iterable and strongly recommend using the change stream directly.

Server Monitoring Fix When Monitoring Events are Skipped

Version 4.7.0 of the Node driver released an improvement to our server monitoring in FAAS environments by allowing the driver to skip monitoring events if there were more than one monitoring events in the queue when the monitoring code restarted. When skipping monitoring events that contained a topology change, the driver would incorrectly fail to update its view of the topology.

Version 4.12.0 fixes this issue by ensuring that the topology is always updated when monitoring events are processed.

Performance Improvements with Buffering

This release also modifies the data structures used internally in the driver to use linked lists in places where random access is not required and constant time insertion and deletion is beneficial.

External Contributions

Many thanks to @ImRodry for helping us fix the documentation for our deprecated callback overloads in this release!

Features

Deprecations

Bug Fixes

Documentation

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

4.11.0

19 Oct 16:29
6fb87e4
Compare
Choose a tag to compare

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

Release Highlights

Recursive Schema Support

Version 4.3.0 of the Node driver added Typescript support for dot notation into our Filter type but
in the process it broke support for recursive schemas. In 4.11.0, we now support mutually recursive schemas and
provide type safety on dot notation queries up to a depth of 8. Beyond a depth of 8, code still compiles
but is no longer type checked (it falls back to a type of any).

interface Author {
    name: string;
    bestBook: Book;
}

interface Book {
    title: string;
    author: Author;
}
 
let authors: Collection<Author>

// below a depth of 8, type checking is enforced
authors.findOne({ 'bestBook.author.bestBook.title': 25 }}) 
// ✅ expected compilation error is thrown: "title must be a string"

// at a depth greater than 8 code compiles but is not type checked (9 deep in this example)
authors.findOne({ 'bestBook.author.bestBook.author.bestBook.author.bestBook.author.name': 25 }) 
// ⛔️ perhaps unexpected, no compilation error is thrown because the key is too deeply nested

Note that our depth limit is a product of Typescript's recursive type limitations.

AWS Authentication

If the optional aws-sdk dependency is installed, the driver will now use the SDK to get credentials
from the environment. Because of this, if you have a shared AWS credentials or config file, then
those credentials will be used by default if AWS auth environment variables are not set. To override this
behavior, set AWS_SHARED_CREDENTIALS_FILE="" in your shell or set the
equivalent environment variable value in your script or application. Alternatively, you can create
an AWS profile specifically for your MongoDB credentials and set the AWS_PROFILE environment
variable to that profile name.

External Contributions

Many thanks to those who contributed to this release!

  • @ermik provided an extremely large schema to test compilation with, which made testing our new recursive schema support possible with large schemas straightforward.
  • @noahsilas for documentation improvements in change streams and fixing our Typescript types for read preferences.
  • @zendagin for adding Typescript support for hashed indexes.
  • @biniona-mongodb for fixing our parsing of TLS options.
  • @LinusU for removing support for server versions lower than our minimum supported server version and improving error messages for unacknowledged writes with hints.

Features

Bug Fixes


Documentation

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

v4.10.0

19 Sep 15:15
dc34388
Compare
Choose a tag to compare

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

Release Highlights

Callback Deprecation

Looking to improve our API's consistency and handling of errors we are planning to remove callback support in the next major release of the driver. Today marks the notice of their removal. Migrating to a promise only API allows us to offer uniform error handling and better native support for automatic promise construction. In this release you will notice deprecation warnings in doc comments for all our callback overloads and if you are working in VSCode you should notice strikethroughs on these APIs. We encourage you to migrate to promises where possible:

  • Using async/await syntax can yield the best experience with promise usage.
  • Using Node.js' callbackify utility is one approach:
    • require('util').callbackify(() => collection.findOne())(callback)
  • Using .then syntax is another:
    • collection.findOne().then(res => callback(null, res), err => callback(err))
  • And lastly, for large codebases still intertwined with callbacks we have an alternative package prepared.

MongoDB-Legacy Callback Support

While the 4.10.0 version only deprecates our support of callbacks, there will be a major version that removes the support altogether. In order to keep using callbacks after v5 is released, we recommend migrating your driver version to mongodb-legacy (github link). This package wraps every single async API our driver offers and is designed to provide the exact behavior of the MongoDB 4.10.0 release (both callbacks and promises are supported). Any new features added to MongoDB will be automatically inherited but will only support promises. This package is fully tested against our current suite and adoption should be confined to changing an import require('mongodb') -> require('mongodb-legacy'). If this package is useful to you and your use case we encourage you to adopt it before v5 to ensure it continues to work as expected.

Read more about it on the package's readme here:

Features

Bug Fixes

Documentation

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

v4.9.1

31 Aug 19:50
Compare
Choose a tag to compare

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

Release Highlights

This is a bug fix release as noted below.

Bug Fixes

v4.9.0

18 Aug 21:08
428bdeb
Compare
Choose a tag to compare

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

Release Highlights

We have corrected an inconsistency with our writeConcern options in the type definitions where the MongoClient alleged to not support "writeConcern" as an option. In fact, it did support it at run time and now the types correctly reflect that, along with the corresponding deprecations we made to the nested writeConcern config settings.

Our index specification handling had a few peculiar edge cases that we have detailed below, we believe these are unlikely to affect a vast majority of users as the type definitions would have likely reported an error with the impacted usage. As a feature, the typescript definitions now support a javascript Map as a valid input for an index specification.

Index Specification Detailed Fixes
  • Map as a valid input type in TS definition
  • Uses Map under the hood to ensure key order is preserved, fixed numeric index key order issue in combination with FLE usage
  • Tuples passed at the top level to createIndex were incorrectly parsed as string input
    • createIndex(['myKey', 1]) would create { 'myKey': 1, '1': 1 }.
    • Now it's correctly detected if the second arg is one of the known index directions.
    • For complex programmatic generation of indexes we recommend using a Map to avoid all the edge cases here.
  • Type strictness on this nesting of array (one or more)
  • Type strictness for createIndexes aligned with createIndex
    • No longer accepts just Document, checks that the values are a known IndexDirection

As per usual this release brings in the latest BSON release (v4.7.0) which added automatic UUID support. You can read more about that in the BSON release notes here!

Special thanks to the folks who contributed to this release!

Features

Bug Fixes

Documentation

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

v4.8.1

26 Jul 19:05
6c3ac96
Compare
Choose a tag to compare

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

Release Highlights

This patch comes with some bug fixes that are listed below as well as a quality of life improvement for nested keys in the UpdateFilter and Filter types. Thanks to @coyotte508 (#3328) for contributing this improvement!

Bug Fixes

Documentation

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

v4.8.0

13 Jul 15:48
be34a94
Compare
Choose a tag to compare

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

Release Highlights

UpdateFilter nested fields

Thanks to a contribution from @coyotte508, in this release you will now get auto-complete and type safety for nested keys in an update filter. See the example below:
image1

Optional client.connect() fixup

In our last release we made explicitly calling client.connect() before performing operations optional with some caveats. In this release client.startSession() can now be called before connecting to MongoDB.

NOTES:

  • The only APIs that need the client to be connected before using are the legacy collection.initializeUnorderedBulkOp() / collection.initializeOrderedBulkOp() builder methods. However, the preferred collection.bulkWrite() API can be used without calling connect explicitly.
  • While executing operations without explicitly connecting may be streamlined and convenient, depending on your use case client.connect() could still be useful to find out early if there is some easily detectable issue (ex. networking) that prevents you from accessing your database.

Features

Bug Fixes

Documentation

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