Complete the code to create an index on the 'age' field in MongoDB.
db.users.createIndex({ age: [1] })In MongoDB, to create an ascending index on a field, you use 1 as the value.
Complete the code to drop an index named 'age_1' from the 'users' collection.
db.users.[1]('age_1')
The correct method to remove an index by name in MongoDB is dropIndex.
Fix the error in the code to create a text index on the 'description' field.
db.products.createIndex({ description: [1] })The value for a text index must be the string 'text' (with quotes) in MongoDB.
Fill both blanks to create a compound index on 'category' ascending and 'price' descending.
db.items.createIndex({ category: [1], price: [2] })Ascending index uses 1 and descending uses -1 in MongoDB.
Fill all three blanks to create a partial index on 'status' equal to 'active' and sort by 'createdAt' descending.
db.records.createIndex({ status: [1], createdAt: [3] }, { partialFilterExpression: { status: [2] } })The index keys specify status: 1 (ascending) and createdAt: -1 (descending), the partialFilterExpression filters where status equals 'active'.