-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Add_to_set does not work with array of hashes/embedded documents.
For example:
Model.create().add_to_set(data: [{a: 1}])
gives:
NoMethodError: undefined method `metadata' for {:a => 1}:Hash
and
Model.create().add_to_set(data: [EmbeddedModel.new])
gives:
NoMethodError: undefined method `__bson_dump__' for #<EmbeddedModel:>
workaround:
m = Model.create() Model.collection.find(_id: m._id).update_all("$addToSet" => { data: {'$each' => [{a:1},{b:2}]} })