but I can't figure out how to do that in prisma
# orm-help
a
but I can't figure out how to do that in prisma
a
@Maciek K Not really, main issue is that only the person that owns a book can have it as their favorite
therefore creating another relation is not desirable
c
If it's many-to-one you can just add a favorite flag to the book table. If it's many-to-many, create an explicit relation with a favorite flag. This has nothing to do with Prisma, it's just basic schema design.
a
@crisu83 My issue is that an owner owns specific books, (These are unique entities) and that an owner can have a single favorite book
it seems like a waste to add a flag to the book table
since it is only going to be on a single time
m
Then mark it on the User side, there you'll have it one time
Copy code
favoriteBookId String?
favoriteBook   Book? @relation(name: "FavoriteBook", fields: [favoriteBookId], references: [id])
Either way you would need to have some checks in the resolver or whatever you're using if a user is favoriting one of his books or not. Depending on how you view this on the frontend, maybe it's not even necessary. If you want to have it checked on the db level you would need to incorporate CHECKS manualy in the DB: https://www.prisma.io/docs/guides/database/advanced-database-tasks/data-validation/postgresql