How can I do a join query for the sole purpose of filtering?
Essentially my question is how can I do this better in drizzle.
I really want to just write
11 Replies
is this multiple tables with from a thing in drizzle?
Drizzle doesn't support selecting from multiple tables yet. You'll need to use a join
You can select only from the table that you need.
How would you rewrite this to do the same thing in a drizzle friendly way, this is how I was taught in school...
also is there a shorthand to return only the properties on teams and avoid the .map? I know I could write out all of the properties manually
You can select whatever you want https://orm.drizzle.team/docs/select
SQL Select - Drizzle ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
You already have the query written, is the innerJoin query that you have, isn't it?
is the innerjoin the best way to do it?
that's what I ultimately landed on but is there a correct way to do it
also I dont see anything in the docs that includes a team.* select for example
You could do a subquery, but in terms of what's better, you'll need to evaluate with some tests I guess
There's no team.* but there's
getTableColumns()
helper function that will get you something equivalentGoodies - Drizzle ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
That looks good thanks
is there a plan to support multiple tables in the future?
or is that a task too difficult for typescript
I don't know about the plan, but usually the join is the canonical way of joining tables
It's what relational dbs do
IMO, using a subquery could even read better:
ahhh, thats cool
Thank you very much