Muhad B K
04/15/2022, 4:30 PMmodel User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String? @unique
mobile String? @unique
}
Muhad B K
04/15/2022, 5:08 PMMuhad B K
04/15/2022, 5:21 PMNOTE:
As noted in the query coverage documentation for partial indexes:
Since MongoDB will not use the partial index for a query or sort operation if using the index results in an incomplete result set.
To use the partial index, a query must contain the filter expression (or a modified filter expression that specifies a subset of the filter expression) as part of its query condition.
EX. to use partial index forfilter you have to use below filter:$type
{ "email": { "$eq": "foo@mail.com", "$type": "string" } }
// or
{ $and: [{ "email": "foo@mail.com" }, { "email": { $type: "string" } }] }
Playground
Vladi Stevanovic
janpio