prisma chobo
04/23/2022, 10:19 PMmodel Role {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
// ****************************************************
application Application @relation(fields: [applicationId], references: [id])
applicationId String
user User[] @relation(fields: [userIds], references: [id])
userIds String[] @db.ObjectId
@@index([applicationId])
@@index([userIds])
@@index([applicationId, userIds])
}
This is a Role schema for mongodb. when I index like above, does it mean Im indexing applicationId only, and userIds only, and both combined applicationId and userids togerther??
So my purposes are
1. i want to get all users in the application (that is why i index @@index([applicationId])
2. I want to get all applications that a user belong to (@@index([userIds])
3. I want to check if a user exists in application (@@index[userids, applicationId])
Is it too much indices? should i get rid of @@index([appicationId, userIds])??
Thank you in advance!!Nurul
04/25/2022, 9:08 AMwhere
clause then it would make sense to create an index on them.
You can look at the Query Plan of your MongoDB query to check if the indexes that you have created are being used or not.