github mongodb/mongo-go-driver v1.9.0
MongoDB Go Driver 1.9.0

latest releases: v1.17.1-cloud1, cloud-1.17-cloud2, vcloud-1.17-cloud1...
2 years ago

The MongoDB Go driver team is pleased to release version 1.9.0 of the official Go driver.

Release Notes

This release contains improvements to connection pool management, an extended API, and a number of bug fixes.

Connection storm mitigation

Previously, the propensity of the driver to inundate a server with new connections during failover events was a particular pain point. This version of the driver contains a number of improvements to mitigate these connection "storms" including:

  • Consider server load during server selection
  • Prevent creating connections to unhealthy servers
  • Re-select a server if that server becomes unhealthy during check-out

Custom Aggregate and ChangeStream options

Certain use-cases may require supplying custom options on aggregate commands. These aggregate operations could be on a Database, Collection or for the creation of a ChangeStream. This version of the driver adds new API to specify custom options in these cases:

Note that all the custom options above must be marshalable into BSON. Users should always prefer using non-custom options where possible.

Let option for CRUD commands

This version of the driver adds a Let option to most CRUD command options. Let can be used to specify parameters for use in an aggregate expression context (e.g. "$$var"). Let must be a document mapping parameter names to values that are constant or closed expressions without references to document fields. Note that the Let option can only be used against server version 5.0 or higher. Let has been added to:

  • AggregateOptions
  • BulkWriteOptions
  • DeleteOptions
  • FindOptions
  • FindOneAndDeleteOptions
  • FindOneAndReplaceOptions
  • FindOneAndUpdateOptions
  • ReplaceOptions
  • UpdateOptions

Cursor and SingleResult constructors

This version of the driver exposes API to create Cursor and SingleResult instances from BSON document(s). In particular, two new constructor functions have been added: NewCursorFromDocuments and NewSingleResultFromDocument. The supplied document(s) must be marshalable and non-nil. These new functions should allow for the mocking of read operation results (such as Find, FindOne and Aggregate) for use in testing.


For a full list of tickets included in this release, please see the links below:

Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

Don't miss a new mongo-go-driver release

NewReleases is sending notifications on new releases.