Complete the code to create a unique index on the "email" field in MongoDB.
db.users.createIndex({ email: 1 }, { unique: [1] })Setting unique: true ensures the index enforces uniqueness on the field.
Complete the code to insert a document that violates a unique index on "username".
db.users.insertOne({ username: [1], age: 25 })String values must be quoted in MongoDB insert commands.
Fix the error in the unique index creation by completing the code.
db.users.createIndex({ email: 1 }, { [1]: true })The correct option name to enforce uniqueness is unique.
Fill both blanks to create a unique index on "phone" field in descending order.
db.contacts.createIndex({ phone: [1] }, { [2]: true })Use -1 for descending order and unique: true to enforce uniqueness.
Fill all three blanks to create a unique compound index on "firstName" ascending and "lastName" descending.
db.users.createIndex({ firstName: [1], lastName: [2] }, { [3]: true })Use 1 for ascending, -1 for descending, and unique: true to enforce uniqueness on the compound index.