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:
This results in a response like this:
Desired Output:
I want to structure the JSON to group
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!
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!