-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.4.4
-
Component/s: BSON
-
None
-
Environment:Linux 4.14
-
None
-
None
-
None
-
None
-
None
-
None
-
None
This fails:
update := bson.D{
{"$set", f},
{"$addToSet", bson.E{"outsideIp", "string"}},
}
updateResult, err := collection.UpdateOne(context.TODO(), filter, update)
This works:
update := bson.D{
{"$set", f},
}
updateResult, err := collection.UpdateOne(context.TODO(), filter, update)
Here is the error message:
multiple write errors: [\{write errors: [{Cannot apply $addToSet to non-array field. Field named 'key' has non-array type string}]}, \{<nil>}]
I only want to use $addToSet with a single string, as documented in the mongodb docs:
db.inventory.update( { _id: 1 }, { $addToSet: { tags: "accessories" } } )
What's going on here?
- is duplicated by
-
GODRIVER-1820 CLONE - BSON encoding, passing single string to $addToSet field
-
- Closed
-
-
GODRIVER-1821 Different with $addToSet in NodeJS and Go drivers
-
- Closed
-
- related to
-
GODRIVER-1819 BSON encoding, passing single string to $addToSet field
-
- Closed
-