Skip to content

Migrate go mongo driver to v2#106

Merged
vikasbolla merged 1 commit into
IBM:mainfrom
vikasbolla:migrate_mongo_driver_v2
Jul 23, 2026
Merged

Migrate go mongo driver to v2#106
vikasbolla merged 1 commit into
IBM:mainfrom
vikasbolla:migrate_mongo_driver_v2

Conversation

@vikasbolla

@vikasbolla vikasbolla commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

As the mongo driver 1.x is getting deprecated, we had to migrate to v2 version as mentioned here-https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo.
I have tested this by branch deployment in the staging env.

@vikasbolla
vikasbolla force-pushed the migrate_mongo_driver_v2 branch from eaa6d54 to 523a1d6 Compare July 8, 2026 09:57
Comment thread api/go.sum Outdated
@vikasbolla
vikasbolla force-pushed the migrate_mongo_driver_v2 branch from 523a1d6 to 414f7d7 Compare July 9, 2026 06:47

@anshuman-agarwala anshuman-agarwala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread api/go.mod Outdated
github.com/swaggo/swag v1.16.6
github.com/tbaehler/gin-keycloak v1.7.0
go.mongodb.org/mongo-driver v1.17.7
go.mongodb.org/mongo-driver/v2 v2.2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update to v2.6.x ? this was released in 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I have added now, thank you

opts := options.Client().ApplyURI(db.URI).SetServerAPIOptions(serverAPI)
client, err := mongo.Connect(context.TODO(), opts)
client, err := mongo.Connect(opts)
if err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFYI, https://pkg.go.dev/go.mongodb.org/mongo-driver/v2@v2.8.0/mongo/options#ClientOptions.SetDialer - I think would be the way to go, if we need to set context

Signed-off-by: Vikas <vikas.satyanarayana.bolla@ibm.com>
@vikasbolla
vikasbolla force-pushed the migrate_mongo_driver_v2 branch from 414f7d7 to 3addf33 Compare July 14, 2026 07:01
@GunaKKIBM

Copy link
Copy Markdown
Member

/lgtm

@vikasbolla
vikasbolla merged commit a26a652 into IBM:main Jul 23, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants