Multiple relation between models
Hello guys, I'm creating a marketplace but I have a problem. I have 2 models:
User
and Post
. I want the user to have the fields posts
(his own posts) and favoritePosts
(the posts he liked).
I made this but it doesn't work:
Can you help me please ?4 Replies
@Mattéo This is what you're looking for:
https://www.prisma.io/docs/orm/prisma-schema/data-model/relations#disambiguating-relations
Relations (Reference) | Prisma Documentation
A relation is a connection between two models in the Prisma schema. This page explains how you can define one-to-one, one-to-many and many-to-many relations in Prisma.
Example from docs
You will need two
user
entries in the Post
model, eg. usersWithThisPost
and usersThatFavouritedThisPost
Thank you @moosthuizen, I’m going to read this