When trying to combine
_, err = d.UpdateByID(ctx, us.UserUUID, bson.M{"$set": updates}, options.Update().SetUpsert(true))
with _, err = d.UpdateByID(ctx, deleteState.UserUUID, bson.M{"$unset": deletes})
into _, err = d.UpdateByID(ctx, us.UserUUID, []bson.M{{"$set": updates}, {"$unset": deletes}}, options.Update().SetUpsert(true))
I get returned multiple write errors: [{write errors: [{$unset specification must be a string or an array}]}, {<nil>}]
I am using Mongo 4.2 on OSX Big Sur with Golang 1.16 and the standard MongoDB driver
Note: I have tried using pipelines, but I get the same error. updates
and deletes
are both type bson.M{}
with keys/values such that updates[key] = value
I will continue to use two separate operations, but I would be interested to know if combining them into a single db call is possible and if not, why.
Best,
Allen