Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLACE mgo with mongodb official driver #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Bolket
Copy link

@Bolket Bolket commented Mar 27, 2019

Hi,
I want use the official mongodb driver instead of mgo.
What do you think about this PR?

@nvcnvn
Copy link
Member

nvcnvn commented Mar 28, 2019

It has been a while since I last doing anything with MongoDB.
How is the community adapting the official driver?
Also, this introduce breaking change, maybe it should handle the versioning properly!

@Bolket
Copy link
Author

Bolket commented Mar 28, 2019

How is the community adapting the official driver?

The last stable release ( 1.0.0 ) of the official driver is 15 days old, the repository on github have 2200 stars, the last commit is two days old.
The mgo project have 1400 stars, and the last commit is pushed the 15 Oct 2018.
I think that more dev switch to official driver.

Also, this introduce breaking change, maybe it should handle the versioning properly!

How can we handle versioning properly?

@nvcnvn I am a beginner with Go, I have a week of experience 😅

@nvcnvn
Copy link
Member

nvcnvn commented Apr 3, 2019

@Bolket here you can check (quite a long topic) https://github.com/golang/go/wiki/Modules
Or maybe you can consider keeping the function signature as the old one.

Comment on lines +202 to +215
count, errFind := m.coll.CountDocuments(context.Background(), bson.M{"_id": idObject})
if err != nil {
return err
return errFind
}

if count > 0 {
_, errUpdate := m.coll.UpdateOne(context.Background(), bson.M{"_id": idObject}, sMap)
if errUpdate != nil {
return errUpdate
}
} else {
_, errInsert := m.coll.InsertOne(context.Background(), s)
if errInsert != nil {
return errInsert

Choose a reason for hiding this comment

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

Is this count then change thread safe?

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.

4 participants