v1.7.0
版本发布时间: 2021-07-21 06:22:42
mongodb/mongo-go-driver最新发布版本:v1.16.1(2024-08-08 03:39:35)
:warning: Retracted
This release has been retracted due to a data race that can occur between creating and checking out connections when minPoolSize > 0.
Please use version 1.7.2 or higher.
The MongoDB Go driver team is pleased to release version 1.7.0 of the official Go driver.
This release supports additional features introduced in MongoDB version 5.0.
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.
Snapshot Reads Without Transaction
Supports using the "snapshot"
read concern outside of transactions for certain operations.
Example of using a Session with "snapshot"
read concern outside of a transaction for a Find
operation:
var client *mongo.Client
// Create a new Session with "snapshot" reads enabled, then create a
// SessionContext with the new Session.
sess, err := client.StartSession(options.Session().SetSnapshot(true))
if err != nil {
panic(err)
}
defer sess.EndSession(context.TODO())
sessCtx := mongo.NewSessionContext(context.TODO(), sess)
coll := client.Database("db").Collection("coll")
cursor, err := coll.Find(sessCtx, bson.D{{"x", 1}})
defer cursor.Close(context.TODO())
// Use the cursor to read Find results with "snapshot" read concern.
Detailed Document Validation Errors
Surface the improved error messages for schema validation in MongoDB 5.0 in WriteException
and BulkWriteException
error messages and via the new field WriteError.Details
.
Release Notes
For a full list of tickets included in this release, please see the links below: