Summary
mgm v3 currently depends on go.mongodb.org/mongo-driver v1. The official MongoDB Go driver has released v2 under the module path go.mongodb.org/mongo-driver/v2. Projects that upgrade to the v2 driver cannot use mgm because of type incompatibility (e.g. *mongo/options.ClientOptions from v1 vs v2).
Motivation
We’d like to use the latest MongoDB Go driver (v2) for new features and long-term support while continuing to use mgm for its ODM features (hooks, config, collections, etc.).
Proposed solution
- Support the v2 driver, e.g. by:
- Updating mgm’s dependency to
go.mongodb.org/mongo-driver/v2 and adapting the code for v2 APIs, or
- Releasing a new major version of mgm (e.g. v4) that targets the v2 driver.
Example of current blocker
When using go.mongodb.org/mongo-driver/v2 with mgm v3.5.0, mgm.SetDefaultConfig(..., options.Client().ApplyURI(uri)) fails with:
cannot use options.Client().ApplyURI(...) (value of type "go.mongodb.org/mongo-driver/v2/mongo/options".ClientOptions)
as "go.mongodb.org/mongo-driver/mongo/options".ClientOptions value in argument to mgm.SetDefaultConfig
Environment
- mgm: v3.5.0
- MongoDB Go driver: v2 (e.g. v2.5.0)
- Go: 1.24
Summary
mgm v3 currently depends on
go.mongodb.org/mongo-driverv1. The official MongoDB Go driver has released v2 under the module pathgo.mongodb.org/mongo-driver/v2. Projects that upgrade to the v2 driver cannot use mgm because of type incompatibility (e.g.*mongo/options.ClientOptionsfrom v1 vs v2).Motivation
We’d like to use the latest MongoDB Go driver (v2) for new features and long-term support while continuing to use mgm for its ODM features (hooks, config, collections, etc.).
Proposed solution
go.mongodb.org/mongo-driver/v2and adapting the code for v2 APIs, orExample of current blocker
When using
go.mongodb.org/mongo-driver/v2with mgm v3.5.0,mgm.SetDefaultConfig(..., options.Client().ApplyURI(uri))fails with:Environment