Loading

Quipoin Menu

Learn • Practice • Grow

mongodb / Delete Operations
mcq
Direction: Choose the correct option

Q1.

Which method deletes a single document that matches a filter?
A. db.collection.remove()
B. db.collection.delete()
C. db.collection.deleteOne()
D. db.collection.removeOne()
Direction: Choose the correct option

Q2.

What does `db.inventory.deleteMany({status: 'obsolete'})` do?
A. Deletes all documents with status 'obsolete'
B. Throws an error
C. Marks documents as obsolete
D. Deletes one document with status 'obsolete'
Direction: Choose the correct option

Q3.

What is returned by a delete operation?
A. A result object with `acknowledged` and `deletedCount`
B. A boolean
C. The deleted documents
D. A count of remaining documents
Direction: Choose the correct option

Q4.

What happens if the filter in `deleteOne()` matches multiple documents?
A. Only the first matching document is deleted
B. All matching documents are deleted
C. The operation fails
D. An error is thrown
Direction: Choose the correct option

Q5.

How do you delete all documents from a collection?
A. db.collection.deleteAll()
B. db.collection.deleteMany({})
C. db.collection.drop()
D. db.collection.truncate()