`where` inside relational queries `with` does not work
Hi there! I'm new to drizzle and tried out the relational queries.
I want to do a nested
where
rule inside a with
relation. But doing it is giving me type errors (Object literal may only specify known properties, and where does not exist in type
) and it's just ignored by the orm.
Maybe someone knows what I am doing wrong and why I don't get the option to do a where
. Thanks in advance!
My query:
My schema (simplified):
4 Replies
how can you apply a
where
to a one
relation?
it always returns a single row@bloberenober Thanks for your quick answer!
So my goal is "select all projects where projects.customer.space.id is equal to..."
So logially the
where
must apply to the projects
, so ideally like this (invalid syntax):
hope this better explains what my goal is.
Another way I guess would be to db.query.customers.findMany
, apply the where
spaceId
to the root and then join into the projects.
If I run the sql directly, it works fine.
You currently cannot filter by a nested relation field, unfortunately
You can query in reverse, if it helps - select all customers where the space ID equals X and include projects in them
@bloberenober I see, alright. Yeah will query it in reverse then. Thanks!