How can I get a better structured response when querying a table (many to many)?
Hi, I am new to sql. This might be obvious, but I'm not sure how to go about this. Below is a simplified example of what I hope to achieve.
I have three tables:
orders
, order_lines
, and items
. order_lines
is a junction table. Here's how I'm currently fetching the data:
This results in a response like this:
Desired Output:
I want to structure the JSON to group order_lines
and items
under each order
:
Is there a way to to do this natively with drizzle, or do I need to manually process the results after fetching them? Would appreciate any help!3 Replies
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
is there a difference in use case for db.query vs. the partial selects? i'm also trying to figure out the same issue.
db.query have ORM DX and it’ll creates SQL automatically, while selects are simple query builders