REPLACE mgo with mongodb official driver#11
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.
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?