How to query many to many? Are the docs out of date?
I've got two tables... Events and Drinks.
Each each event can have multiple drinks, and a drink can be in multple events. So I've setup a many-to-many relation as per the docs. (https://orm.drizzle.team/docs/rqb#many-to-many)
schema: https://gist.github.com/magicspon/b52863a5f3b8660665e9f36d327b8cc2
When I try an run this query:
VS Code says no, "eventsToDrink" doesn't exist on events... Yet it is auto suggested in drizzle studio..
When I run the query in drizzle studio, i get an error
5 Replies
I can get the
snaps
related items (one-to-many) with the with
syntax... but many-to-many is a dead duckSee if it helps to add a relation name to the relations.
The related relations should have the same name to associate it.
eg:
You should change the relation key
The key used in the rqb object should match the relation key
Alternatively
You can try @Sillvva example here: https://drizzle.run/ark1boqh4pq1904m4alcyyam
Drizzle Run
Many to many with query API - Drizzle Run
Amazing... thanks @MrRazia @Sillvva @Raphaël M (@rphlmr) ⚡