Skip to content

Commit

Permalink
Merge pull request #3 from davidfu13/main
Browse files Browse the repository at this point in the history
fix(condition): update document must contain key beginning with '$'
  • Loading branch information
wdhongtw authored Aug 9, 2022
2 parents bb56a5a + 3dd1197 commit 0a9ceb7
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 0a9ceb7

Please sign in to comment.