Using column of relation in where clause

I would like to do something like this:
database.query.tableOne.findMany({
with: {
tableTwo: {
columnOne: true
}
}
where: eq(tableTwo.columnOne, 10)
})
database.query.tableOne.findMany({
with: {
tableTwo: {
columnOne: true
}
}
where: eq(tableTwo.columnOne, 10)
})
The above query causes the following error: missing FROM-clause entry for table "tableTwo" Is there any way to do this?
2 Replies
rphlmr ⚡
rphlmr ⚡5mo ago
There is a “hack” you can try. https://drizzle.run/brfzfblyhllb7dz24d630px3 Note: it is really something that can break at any moment
rphlmr ⚡
rphlmr ⚡5mo ago
At every “level” there is a “data” alias representing the sub query. If you try on drizzle run, you have an option to output the queries that has been ran. This is how I reverse engineered that 😅
Want results from more Discord servers?
Add your server