I am trying to create a complex id
for my model which combines a custom string field and an @autoincrement
field. Here is what I have tried.
model Order {
orderNo Int @unique @default(autoincrement())
prefix String @default("SMO-SP-") // generated based on order source and shipping method
orderType OrderType @default(CUSTOM)
@@id(name: "id", [prefix, orderNo])
}
model OrderItem {
id Int @id @default(autoincrement())
orderId String
order Order @relation(fields: [orderId], references: [id])
quantity Int
}
I expected the named id
field would be used as a reference but throws the error
Error validating: The argument `references` must refer only to existing fields in the related model `Order`. The following fields do not exist in the related model: id
I cant seem to find a solution in the prisma documentation.