I am trying to teach myself Meteor and Mongo. I have a particular insertion inside my Meteor method that is driving me nuts.
My document object looks like this:
{
_id
name: "name",
stuff: {},
array: [
{
id: 0,
target:[
{
id: 0,
name: "1"
},{
id: 1,
name: "2"
}
]
},{
id: 1,
target:[
{
id: 0,
name: "A"
},{
id: 1,
name: "B"
}
]
}
],
}
I am trying to add objects into the target array, which is inside an object inside the array-array.
I have tried a number of different approaches over a few days based on some things I have seen here on stack overflow. The most recent attempt is:
Documents.update({_id: id, 'array.id': arrayId}, {$addToSet:{'array.$.target': objectToInsert}},{upsert: false, multi: false})
If anyone could point me in the right direction I would appreciate it.