21.) What is the purpose of the $set operator in MongoDB?
A) To replace a document
B) To remove fields from a document
C) To update specific fields
D) To create a collection
22.) How do you query documents where a field is not equal to a specific value?
A) $not
B) $ne
C) $neq
D) $notEq
23.) Which of the following is true about MongoDB collections?
A) They require a fixed schema.
B) Fields must be consistent across all documents.
C) They are schema-less.
D) They do not support indexing.
24.) Which command removes all documents from a collection?
A) db.collection.drop()
B) db.collection.deleteMany({})
C) db.collection.removeAll()
D) db.collection.delete()
25.) What is the purpose of the $unset operator?
A) To add new fields
B) To remove fields from a document
C) To delete a document
D) To replace a collection
26.) How can you check the structure of a collection’s documents?
A) db.collection.show()
B) db.collection.explain()
C) db.collection.findOne()
D) db.collection.structure()
27.) Which operator checks if a field exists in a document?
A) $exists
B) $field
C) $match
D) $include
28.) What is the purpose of the $push operator?
A) Add a field
B) Append a value to an array
C) Update multiple documents
D) Delete an array
29.) Which of the following methods creates a new collection?
A) db.createCollection()
B) db.collection.new()
C) db.newCollection()
D) db.collection.insert()
30.) Which MongoDB function ensures unique field values across documents?
A) $unique
B) createIndex({field: 1}, {unique: true})
C) db.collection.setUnique()
D) db.collection.addConstraint()
Related