Skip to content

Commit 0a9ceb7

Browse files
authored
Merge pull request #3 from davidfu13/main
fix(condition): update document must contain key beginning with '$'
2 parents bb56a5a + 3dd1197 commit 0a9ceb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mtest/collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (r *Assert) Empty() *Assert {
118118

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

0 commit comments

Comments
 (0)