Mulitple index for json field
I want to add index per json field's sub field
I am using MongoDB with Prisma
Here is the schema definition
But I got this error
How can I fix this problem?
I am using MongoDB with Prisma
Here is the schema definition
model Chat {
id String @id @default(auto()) @map("_id") @db.ObjectId
messages Json[]
description String?
creatorId String @db.ObjectId
metadata IChatMetadata?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
creator User @relation(fields: [creatorId], references: [id])
@@index([creatorId])
@@index([metadata(path: "published")], map: "ai_chats_metadata_published_idx")
@@index([metadata(path: "isPublic")], map: "ai_chats_metadata_isPublic_idx")
@@map("ai_chats")
}
type IChatMetadata {
gitUrl String?
gitBranch String?
customUrl String?
published Boolean? @default(false)
isPublic Boolean? @default(true)
}model Chat {
id String @id @default(auto()) @map("_id") @db.ObjectId
messages Json[]
description String?
creatorId String @db.ObjectId
metadata IChatMetadata?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
creator User @relation(fields: [creatorId], references: [id])
@@index([creatorId])
@@index([metadata(path: "published")], map: "ai_chats_metadata_published_idx")
@@index([metadata(path: "isPublic")], map: "ai_chats_metadata_isPublic_idx")
@@map("ai_chats")
}
type IChatMetadata {
gitUrl String?
gitBranch String?
customUrl String?
published Boolean? @default(false)
isPublic Boolean? @default(true)
}But I got this error
Error parsing attribute "@@index": Index already exists in the model.Prisma
Error parsing attribute "@@index": The given constraint name `ai_chats_metadata_idx` has to be unique in the following namespace: on model `AiChat` for indexes and unique constraints. Please provide a different name using the `map` argument.PrismaError parsing attribute "@@index": Index already exists in the model.Prisma
Error parsing attribute "@@index": The given constraint name `ai_chats_metadata_idx` has to be unique in the following namespace: on model `AiChat` for indexes and unique constraints. Please provide a different name using the `map` argument.PrismaHow can I fix this problem?