0
0
MongoDBquery~10 mins

Delete with filter conditions 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" equals "inactive".

MongoDB
db.collection.deleteMany({"status": [1])
Drag options to blanks, or click blank then click option'
Ainactive
B"active"
C"inactive"
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string value.
Using the field name as the value.
2fill in blank
medium

Complete the code to delete a single document where the "username" is "guest".

MongoDB
db.collection.[1]({"username": "guest"})
Drag options to blanks, or click blank then click option'
AdeleteOne
Bremove
CdeleteMany
Ddrop
Attempts:
3 left
💡 Hint
Common Mistakes
Using deleteMany which deletes multiple documents.
Using drop which deletes the whole collection.
3fill in blank
hard

Fix the error in the code to delete documents where "age" is greater than 30.

MongoDB
db.collection.deleteMany({"age": [1] 30})
Drag options to blanks, or click blank then click option'
A$lt:
B$gt:
C>
D$gte:
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of $gt.
Omitting the colon after the operator.
4fill in blank
hard

Fill both blanks to delete documents where "score" is less than 50 and "passed" is false.

MongoDB
db.collection.deleteMany({"score": [1] 50, "passed": [2])
Drag options to blanks, or click blank then click option'
A$lt:
Bfalse
Ctrue
D$gt:
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of < for score.
Using string "false" instead of boolean false.
5fill in blank
hard

Fill all three blanks to delete documents where "category" is "electronics", "price" is greater than 100, and "inStock" is true.

MongoDB
db.collection.deleteMany({"category": [1], "price": [2] 100, "inStock": [3])
Drag options to blanks, or click blank then click option'
A"electronics"
B$gt:
Ctrue
D"clothing"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around "electronics".
Using > instead of $gt.
Using string "true" instead of boolean true.