Can I connect an existing User record to an existi...
# orm-help
a
Can I connect an existing User record to an existing Post record? I want to have a simple favorites feature.
Copy code
model User {
  uid String @id @default(uuid())
  username String? @db.VarChar(24) @unique  
  favorites Post[]

model Post {
  id             Int     @id @default(autoincrement())
  title           String  @db.VarChar(255)
  favoritedBy User[]
}
How does the mutation look like for adding a favorite to the user ?
😕 1
Here is the query that doesnt work unfortunately: const response = prisma.user.update({ where: { uid: context.user.uid, }, data: { favorites: { connect: { id: 1 } } }, })
n
What error are you getting?