Complete the code to find all documents in the 'users' collection.
db.users.[1]()The find() method retrieves documents from a collection. Here, it fetches all documents from 'users'.
Complete the code to find users older than 25.
db.users.find({ age: { [1]: 25 } })The $gt operator means 'greater than'. So this query finds users with age greater than 25.
Fix the error in the query to find users with name 'Alice'.
db.users.find({ name: [1] })String values in MongoDB queries must be quoted. Using 'Alice' correctly specifies the string.
Fill both blanks to find users with age between 20 and 30.
db.users.find({ age: { [1]: 20, [2]: 30 } })$gte means 'greater than or equal to' and $lte means 'less than or equal to'. Together they find ages between 20 and 30 inclusive.
Fill all three blanks to create an index on the 'email' field in ascending order.
db.users.createIndex({ [1]: [2] }, { unique: [3] })Creating an index on 'email' with ascending order (1) and setting unique to true ensures no duplicate emails.