Complete the code to create an index on the 'age' field.
db.users.createIndex([1]: 1})
The index is created on the 'age' field to optimize queries filtering by age.
Complete the query to find users aged 30 using the index.
db.users.find([1]: 30})
The query filters users by the 'age' field, which is indexed for faster lookup.
Fix the error in the index creation by choosing the correct index type for a covered query.
db.users.createIndex([1]: 1})
Covered queries require the index to include the fields used in the query and projection. Indexing 'age' supports this.
Fill both blanks to create a compound index on 'age' and 'name' for a covered query.
db.users.createIndex([1]: 1, [2]: 1})
A compound index on 'age' and 'name' supports queries filtering and projecting these fields, enabling covered queries.
Fill all three blanks to write a covered query that uses the compound index on 'age' and 'name' and projects only 'name'.
db.users.find([1]: 25}, [2]: 1, [3]: 0})
The query filters by 'age', projects 'name', and excludes '_id' to use the compound index for a covered query.