How do I reuse the results from the where clause within the findMany?
I have a vendor ID and want to retrieve all restaurant IDs and menu IDs associated with that vendor. Can I use the same ID I passed in the where clause for menus as the value for the restaurant ID received in the first where clause?
3 Replies
my schema
the relations
The query that might not be working?
I wonder if I should use join instead? but I thought findMany is similar to join?
@Chi Hao when you use drizzle relational queries, there is no need to add the where clause for the nested relations, these are automatically applied in the background (https://orm.drizzle.team/docs/rqb#include-relations)
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
hi @Aaroned , I wonder why I'm getting this error
TypeError: Cannot read properties of undefined (reading 'referencedTable')
?
this is the code
ok fixed, i forgot to export the relations in drizzle()