Complete the code to delete all documents where the field "status" equals "inactive".
db.collection.deleteMany({"status": [1])The filter must match documents where the "status" field is the string "inactive". So the value must be a string in quotes.
Complete the code to delete a single document where the "username" is "guest".
db.collection.[1]({"username": "guest"})
To delete a single document matching a filter, use deleteOne. deleteMany deletes all matching documents.
Fix the error in the code to delete documents where "age" is greater than 30.
db.collection.deleteMany({"age": [1] 30})MongoDB uses query operators like $gt for 'greater than'. It must be a key in an object, so the colon is needed.
Fill both blanks to delete documents where "score" is less than 50 and "passed" is false.
db.collection.deleteMany({"score": [1] 50, "passed": [2])Use $lt for 'less than' and the boolean false for the "passed" field.
Fill all three blanks to delete documents where "category" is "electronics", "price" is greater than 100, and "inStock" is true.
db.collection.deleteMany({"category": [1], "price": [2] 100, "inStock": [3])The category is the string "electronics" (with quotes), the price filter uses $gt for 'greater than', and inStock is the boolean true.