Schema issues with split files, relational queries
I'm having issues getting db queries to work with split schema files. My config (drizzle.config.ts) looks like:
and my folder structure:
and when I do stuff like (auth user is in users.ts)
I get the error
So it seems like it can't load my table structure.
When I had my schema in a single file, it was easy just do do
But I can't figure out how to do that when I have separate schema files?
7 Replies
@zicho
This works with schemas in different files
thanks! I did manage to fix it in another way though:
It would be nice to have some examples in the docs though, so I submitted a suggestion. Let's hope it comes through
Alright. Thank you!
@zicho Do you have any idea how to query one-to-many from the many side and check where on the one side?
Hm, what data is is that you want? All "otp" where the email is:
- equal to user email and
- equal to code and equal to status: pending?
how does the table structure look?
Figured it out but from the user's table not otp
So I want to do that inversely from the OTP table not users table
I'm trying to get otp where code = '' and status = '' and where the related user email = ''
dynamic import of schema files in a directory, exported into one object
They removed the ability to filter by nested relations in an earlier release: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.28.0
GitHub
Release 0.28.0 · drizzle-team/drizzle-orm
Breaking changes
Removed support for filtering by nested relations
Current example won't work in 0.28.0:
const usersWithPosts = await db.query.users.findMany({
where: (table, { sql }) => (...