Skip to content

4.11.0

Compare
Choose a tag to compare
@baileympearson baileympearson released this 19 Oct 16:29
· 658 commits to main since this release
6fb87e4

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.