Basic Document Retrieval
Which query will find all documents in the 'users' collection where the 'age' field is greater than 30?
- { age: { $gt: 30 } }
- { age: { $lt: 30 } }
- { age: { $gte: 30 } }
- { age: { $eq: 30 } }
- { 'age' u003E 30 }
Updating Multiple Fields
How would you correctly update both the 'name' and 'email' fields for a single document using the updateOne method?
- { $set: { name: 'Sam', email: 'sam@example.com' } }
- { set: { name: 'Sam', email: 'sam@example.com' } }
- { $update: { name: 'Sam', email: 'sam@example.com' } }
- { $set: [ name: 'Sam', email: 'sam@example.com' ] }
- { $modify: { name: 'Sam', email: 'sam@example.com' } }
Logical Query Operators
Which operator is used in MongoDB to combine multiple conditions with a logical AND?
- $and
- $or
- $not
- u0026and
- $nand
Using Aggregation Framework
Which aggregation stage allows you to group documents by a specified field and perform accumulations like sum or average?
- $group
- $sort
- $project
- $limit
- $concat
Querying Embedded Documents
How would you find documents where the 'address.city' field equals 'London'?
- { 'address.city': 'London' }
- { address.city = 'London' }
- { address: { city: 'London' } }
- { address_city: 'London' }
- { 'address-city': 'London' }
Array Field Matching
If you want to find documents with at least one element in the 'tags' array equal to 'active', which query do you use?
- { tags: 'active' }
- { tags: { $eq: ['active'] } }
- { tags: { $contains: 'active' } }
- { $in: { tags: 'active' } }
- { tags: { $equals: 'active' } }
Aggregation Sorting
Which aggregation stage is used to sort the output documents by a particular field in descending order?
- { $sort: { field: -1 } }
- { $order: { field: -1 } }
- { $sortBy: { field: -1 } }
- { $descending: { field: 1 } }
- { $orderby: { field: -1 } }
Field Renaming in Aggregation
Which aggregation operator allows you to change field names or include/exclude fields in documents?
- $project
- $rename
- $update
- $replace
- $modify
Querying for Null Values
How would you retrieve documents in the 'order' collection where the field 'deliveryDate' is missing or set to null?
- { deliveryDate: null }
- { deliveryDate: { $null: true } }
- { deliveryDate: { $isNull: true } }
- { deliveryDate = NULL }
- { deliveryDate: undefined }
Updating Array Elements
Which update operator is used to add an item to an array field within a document?
- $push
- $add
- $append
- $inc
- $arrayAdd