KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a documents in MongoDB, one of them looks like this: { "_id" : 100, "name" : "Something", "items" : [ { "item" : 47, "color" : "red" }, { "item" : 44, "color" : "green" }, { "item" : 39, "color" : "blue" } ] } In every document I need to find the minimum item and delete it. So it should be like this: { "_id" : 100, "name" : "Something", "items" : [ { "item" : 47, "color" : "red" }, { "item" : 44, "color" : "green" } ] } It looks like findAndModify function should be used here but I can't go any further. How to find the minimum element in array and delete it? I'm using MongoDB and Pymongo driver.
Tags (comma-separated)
Save Edits
Cancel