How to add a custom field on query result?
I have an implicit many-to-many relation: User and Post. A user could like many posts, and a post could be liked by many users.
Here is the schema:
Now I want to get the post lists to render. For every post, there will be a heart showing if it's already liked by current user. How could I get a structure with type
Post & { isLiked: boolean }
? It would be perfect if it could be done in one query.1 Reply
This has been answered in this Github Discussion
GitHub
How to add a custom field on query result? · prisma prisma · Discus...
Question I have an implicit many-to-many relation: User and Post. A user could like many posts, and a post could be liked by many users. Here is the schema: model User { id String @id @default(dbge...