Answer the question
In order to leave comments, you need to log in
How to add an element to a specific nested array in MongoDB?
There is this document, is it possible to somehow insert a new element into the nested array "accounts_data.0.accounts", but not by such a request, but by searching for accounts_data.name?
For example find an array where the field "name" = 'instagram w. 18+' and add a new element to its accounts field
Answer the question
In order to leave comments, you need to log in
It's possible, like this:
db.test.updateOne({"accounts_data.name": "instagram ж. 18+"}, {$push: {"accounts_data.$.accounts": 1} })
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question