I am attempting to modify an array within my collection using the following method:
var str = "list.0.arr";
db.collection('connect').update({_id: id}, {$push: { `${str}`: item}});
While the above code works perfectly fine, it throws an error Unexpected token
when written like this:
db.collection('connect').update({_id: id}, {$push: { "list.0.arr": item}});
My query is, how can I make the first approach work with the object key?