Details
-
Bug
-
Resolution: Gone away
-
Major - P3
-
None
-
1.7.4
-
None
-
Not Needed
Description
MogoDB version: 5.0.3
Driver version: v1.7.4
Code:
type mongoCounter struct {
Type string `bson:"type"`
Sequence int `bson:"sequence"`
}
result := mongoCounter{}
err = db.Collection("counters").FindOneAndUpdate(context.Background(), bson.M{
"type": "non_existen_type",
}, bson.M{
"$inc": bson.M{
"sequence": 1,
},
}, options.FindOneAndUpdate().SetUpsert(true)).Decode(&result)
fmt.Println(err)
Result:
mongo: no documents in result
Expected:
The document should be created and err is nil.