Is this query possible using the Query API?

I have this query:
db.query.usersTable.findFirst({ with: { userDetails: true }, where: eq(userDetailsTable.email, email) });
db.query.usersTable.findFirst({ with: { userDetails: true }, where: eq(userDetailsTable.email, email) });
but when ran it throws the error column usersTable.email does not exist even though I'm trying to filter based on userDetailsTable. Is this query not possible using the Query API or am I just doing it incorrectly?
2 Replies
Angelelz
Angelelz5w ago
You're trying to filter based on a related table. This is possible but you have to use a subquery You can use this as an example https://discord.com/channels/1043890932593987624/1303405402230100069 Meant to use this one https://discord.com/channels/1043890932593987624/1291472979003314320/1291745731505426494
lewisedc
lewisedcOP3w ago
Sorry for late reply, didn't realise anyone replied to me haha, used your example of a subquery and it worked great, thanks for the help!
Want results from more Discord servers?
Add your server