Skip to content

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