MongoDB Node.js Driver 4.9.0 Released

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!

  • sampaiodiego for the oplogReplay flag support fix
  • jer-sen for typescript Filter definition improvements
  • aditi-khare-mongoDB for index specification fixes / type improvements

Features

  • NODE-3517: improve index spec handling and type definitions (#3315) (0754bf9)
  • NODE-4336: deprecate old write concern options and add missing writeConcern to MongoClientOptions (#3340) (d2b6ad8)

Bug Fixes

  • NODE-4159,NODE-4512: remove servers with incorrect setName from topology and fix unix socket parsing (#3348) (00dcf2d)
  • NODE-4273: pass ‘comment’ option through to distinct command (#3339) (753ecfe)
  • NODE-4413: set maxTimeMS on getMores when maxAwaitTimeMS is specified (#3319) (dcbfd6e)
  • NODE-4429: select server sync for endSessions during close (#3363) (5086ead)
  • NODE-4467: Add back support for oplogReplay option as deprecated (#3337) (6c69b7d)
  • NODE-4496: counter values incorrectly compared when instance of Long (#3342) (d29eb8c)
  • NODE-4513: type for nested objects in query & update (#3349) (ec1a68f)

Documentation

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

1 Like

This topic was automatically closed after 90 days. New replies are no longer allowed.