I have a document structure like
{ "_id" : ObjectId("52263922f5ebf05115bf550e"), "Fields" : [ { "Field" : "Lot No", "Rules" : [ ] }, { "Field" : "RMA No", "Rules" : [ ] } ] }
I tried updating using the following code to insert into an array of rules that will contain objects.
db.test.update({ "Fields.Field":{$in:["Lot No"]} }, { $addToSet: { "Fields.Field.$.Rules": { "item_name": "my_item_two", "price": 1 } } }, false, true);
But I get the following error:
cannot join array using string field name [Field]
How to make an update?
source share