I can’t add an object containing a property associated with an array of objects to mongoDB, below I put my code, I’ve already used $push elsewhere and it worked, but here it doesn’t work, it returns the matchedCount: 1 and that the modifiedCount: 0.
let obj = { "ordine": [...data.order] };
result = await restaurantsCollection.updateOne(
{ 'nameRestaurant': data.nameRestaurant },
{
$push: { 'restaurant.$[elem].tavolo.temp.$[elem2].ordini': obj }
},
{
arrayFilters: [
{ 'elem.tavolo.numTavolo': data.numTavolo },
{ 'elem2.active': true }
]
}
);