I am new to Mongo and I have a question about deleting documents using PyMongo.
I have a collection called mycollection. It has documents looking like this:
{
"field1":"value1",
"field2":"value2",
"array_field": [
"id1",
"id2
]
}
I want to delete all documents in the collection which has id1 in the array_field.
How can I do this? (I am using PyMongo, I would appreciate examples based on it :) )
db.collection.deleteMany("array_field": "id1"). You just have to adapt it to your specific driver. Doc : mongodb.com/docs/manual/tutorial/query-arrays and mongodb.com/docs/manual/reference/method/…