mongo delete document code example
Example 1: how to delete a document in mongodb
to delete a document
db.games.deleteOne({name:"Snake"})
Example 2: mongo delete all documents
db.bios.remove( { } )
Example 3: delete an item from db collection mongodb
db.collection.remove(
<query>,
{
justOne: <boolean>,
writeConcern: <document>
}
)
Example 4: how to delete subdocument mongodb
db.getCollection('products').update({},
{$pull: {reviews:
{user: ObjectId("5f6e2e0b70eb0208fc84011a")}}},
{multi: true})