Unable to query a table with another many to many relation

This seems to be an issue with the type handling, but it also could be an oversight on my part. I have 3 tables, let's call them A, B, and C. A and B have a one to many relation, and B and C also has another one to many relation. I have references to A from B, and references to B from C, but none from A to C. I'm trying to query B using db.query.B.findFirst({with: {C: true}), so I can get the C records of B. The inferred type of with ends up becoming {}, and as a result the response of that doesn't have the types for the relation. On the other hand, if I delete the relations between A and B from my drizzle schema file, the query works fine. What gives?
6 Replies
sixfalls
sixfallsOP6mo ago
Oversight, didnt know there should only be one relations for each table
Nahyer
Nahyer3w ago
true can't use both where and with at the same time (started using drizzle this month)
Angelelz
Angelelz3w ago
This is not true. Can you share you schema? There might be an error in your relation definition You can have as many relations as you want
sixfalls
sixfallsOP3w ago
one export for schema.ts for each table, i had to move all the relations into one
Angelelz
Angelelz3w ago
If I don't see the code I cannot help
sixfalls
sixfallsOP2w ago
I resolved this in the 2nd message.
Want results from more Discord servers?
Add your server