How to model my Prisma for a Golf-application
I have this golf application where all Users have their own bags. Inside their bags they have several Golf clubs.
I want to fetch their bags and also list out all the golf clubs inside their respective bags.
How could I achieve this? I guess I can't look inside the bag and see what clubs there is inside there. That instead, I'll have to look at the clubs and see if their Id's is inside a bag. like
But since the bagId is just a string. I can't like map over each bag and use their id against this procedure. Cause in my database, the bagId is null on the discs. And also just a singular string.
Solution:Jump to solution
get the bag and include clubs? https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries
Prisma
Relation queries (Concepts)
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
2 Replies
Solution
get the bag and include clubs? https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries
Prisma
Relation queries (Concepts)
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
Oh shit! Didn't even know you could query relations. Thought you had to do some reverse stuff to get the respective model. Thanks... 😅