-
Notifications
You must be signed in to change notification settings - Fork 39
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
base: master
Are you sure you want to change the base?
Conversation
It has been a while since I last doing anything with MongoDB. |
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.
How can we handle versioning properly? @nvcnvn I am a beginner with Go, I have a week of experience 😅 |
@Bolket here you can check (quite a long topic) https://github.com/golang/go/wiki/Modules |
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 |
There was a problem hiding this comment.
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?
Hi,
I want use the official mongodb driver instead of mgo.
What do you think about this PR?