Skip to content

Support for MongoDB Go driver v2 (go.mongodb.org/mongo-driver/v2) #95

Description

@Rahulkohli10

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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions