Skip to content

Commit

Permalink
fix(condition): update document must contain key beginning with '$'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfu13 committed Aug 9, 2022
1 parent bb56a5a commit 3dd1197
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mtest/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (r *Assert) Empty() *Assert {

func conditionExists(t *testing.T, col *mongo.Collection, documents ...interface{}) {
for _, document := range documents {
_, err := col.UpdateOne(context.TODO(), document, options.Update().SetUpsert(true))
_, err := col.UpdateOne(context.TODO(), document, bson.M{"$set": document}, options.Update().SetUpsert(true))
if err != nil {
t.Fatalf("can not ensure document [%#v] in collection [%v]: %v", document, col.Name(), err)
}
Expand Down

0 comments on commit 3dd1197

Please sign in to comment.