I\'m trying to update an array in my collection with this:
var str = \"list.0.arr\"; db.collection(\'connect\').update({_id: id}, {$push: { `${str}`: i
Create the update document with the string as key prior to using it in the update:
var str = "list.0.arr", query = { "_id": id }, update = { "$push": {} }; update["$push"][str] = item; db.collection('connect').update(query, update);