Complete the code to create an ascending index on the "name" field.
db.collection.createIndex({ name: [1] })The value 1 specifies an ascending index in MongoDB.
Complete the code to create a unique index on the "email" field.
db.users.createIndex({ email: 1 }, { [1]: true })The unique option ensures no duplicate values in the indexed field.
Fix the error in the code to create a descending index on the "date" field.
db.events.createIndex({ date: [1] })Use -1 to specify a descending index in MongoDB.
Fill both blanks to create a TTL index on the "createdAt" field that expires documents after 3600 seconds.
db.logs.createIndex({ createdAt: [1] }, { [2]: 3600 })The index direction is 1 (ascending), and expireAfterSeconds sets the TTL duration.
Fill all three blanks to create a compound index on "lastName" (ascending) and "age" (descending) with background building enabled.
db.people.createIndex({ lastName: [1], age: [2] }, { [3]: true })The compound index uses ascending (1) for lastName, descending (-1) for age, and builds in the background with background: true.