Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumMongoDBpartial and sparse indexesSingle-choice MCQ

You create a unique partial index to enforce uniqueness only on documents where `deleted` is false. Two documents both have `deleted: true` and the same `username`. What happens on insert of the second one?

db.users.createIndex( { username: 1 }, { unique: true, partialFilterExpression: { deleted: false } } )