Answer the question
In order to leave comments, you need to log in
How to remove an array element in mongoDB?
There is a given structure in MongoDB
How can I find the element that is highlighted in red and remove only that element from the array?
Tried
db.online_service.update_one({'id': 'inst'}, {'$pull': {'accounts_data.$': {'id': 'inst_f18+'}}})
db.online_service.update_one({' id': 'inst'}, {'$pull': {'accounts_data.$.id': 'inst_f18+'}})
and various variations, but to no avail.
Thanks in advance for your reply
Answer the question
In order to leave comments, you need to log in
General example (edit for yourself):
db.online_service.update(
{ },
{ $pull: { accounts_data: { $elemMatch: { id: "inst_f18+" } } } },
{ multi: true }
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question