You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The @unique restrictions in SavedPost { userId and postId} generates an error when you try to save a post with different accounts, limiting the Save function to a single user.
Improved code:
model SavedPost {
id String @id@default(auto()) @Map("_id") @db.ObjectId
user User @relation(fields: [userId], references: [id])
post Post @relation(fields: [postId], references: [id])
userId String @db.ObjectId
postId String @db.ObjectId
createdAt DateTime @default(now())
The @unique restrictions in SavedPost { userId and postId} generates an error when you try to save a post with different accounts, limiting the Save function to a single user.
Improved code:
model SavedPost {
id String @id @default(auto()) @Map("_id") @db.ObjectId
user User @relation(fields: [userId], references: [id])
post Post @relation(fields: [postId], references: [id])
userId String @db.ObjectId
postId String @db.ObjectId
createdAt DateTime @default(now())
@@unique([userId, postId])
}
The text was updated successfully, but these errors were encountered: