0
0
MongoDBquery~10 mins

deleteMany method in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to delete all documents where the field "status" is "inactive".

MongoDB
db.collection.deleteMany({ status: [1] })
Drag options to blanks, or click blank then click option'
Anull
B"active"
Ctrue
D"inactive"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around string values.
Using deleteOne instead of deleteMany.
2fill in blank
medium

Complete the code to delete all documents where the "age" field is greater than 30.

MongoDB
db.collection.deleteMany({ age: { [1]: 30 } })
Drag options to blanks, or click blank then click option'
A$lt
B$eq
C$gt
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt which means less than.
Using $eq which means equal.
3fill in blank
hard

Fix the error in the code to delete documents where "score" is less than or equal to 50.

MongoDB
db.collection.deleteMany({ score: { [1]: 50 } })
Drag options to blanks, or click blank then click option'
A$lte
B$gte
C$gt
D$eq
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gte which means greater than or equal.
Using $eq which means equal only.
4fill in blank
hard

Fill both blanks to delete documents where "category" is "books" and "price" is less than 20.

MongoDB
db.collection.deleteMany({ category: [1], price: { [2]: 20 } })
Drag options to blanks, or click blank then click option'
A"books"
B"electronics"
C$lt
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong category string.
Using $gt instead of $lt.
5fill in blank
hard

Fill all three blanks to delete documents where "status" is "pending", "priority" is greater than 3, and "assigned" is false.

MongoDB
db.collection.deleteMany({ status: [1], priority: { [2]: 3 }, assigned: [3] })
Drag options to blanks, or click blank then click option'
A"pending"
B$gt
Cfalse
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using true instead of false for assigned.
Forgetting quotes around "pending".
Using wrong operator for priority.