radisa
04/27/2022, 5:18 AMmodel User {
walletAddress String @id
twitterHandle String?
website String?
bio String?
username String?
signedAt DateTime @default(now())
logs Log[]
@@map("users")
}
model Log {
id Int @id @default(autoincrement())
from User? @relation("fromAddressRelation", fields: [fromAddress], references: [walletAddress])
fromAddress String?
to User? @relation("toAddressRelation", fields: [toAddress], references: [walletAddress])
toAddress String?
createdAt DateTime @default(now())
@@map("logs")
}
The from
and to
property in the Log
model gives me an error says that "Error validating field from
in model `Log`: The relation field from
on Model Log
is missing an opposite relation field on the model User
. Either run prisma format
or add it manually". I want to User
model only has one Log
relation. How do I fix this? Thank youNurul
04/27/2022, 7:29 AMmodel User {
walletAddress String @id
twitterHandle String?
website String?
bio String?
username String?
signedAt DateTime @default(now())
fromLogs Log[] @relation("fromAddressRelation")
toLogs Log[] @relation("toAddressRelation")
@@map("users")
}
model Log {
id Int @id @default(autoincrement())
from User? @relation("fromAddressRelation", fields: [fromAddress], references: [walletAddress])
fromAddress String?
to User? @relation("toAddressRelation", fields: [toAddress], references: [walletAddress])
toAddress String?
createdAt DateTime @default(now())
@@map("logs")
}
Prisma requires that every relation field must be on both sides of the modelradisa
04/27/2022, 8:30 AMUser
model?Nurul
04/27/2022, 9:06 AM