findMany with custom field
Currently, I have a code to fetch order details by aggregating several tables (Order, Customer, and Order Line Items tables). I've read the documentation about
.findMany()
and this is what I'm able to do
The code currently can return something like below
I want to fetch name
from Service Table, and replace serviceId
with it where serviceId = service.id
. How can I achieve that? I've read https://orm.drizzle.team/docs/rqb#include-custom-fields but I still can't get it to work.Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Solution:Jump to solution
It's not possible with query api.
But you can add a relation for Order Line Items table to get your service (you will then be able to add a
with
in orderLineItems
).
For the final mapping shape, it will be in pure JS....3 Replies
What i want is for it to look something like this
Solution
It's not possible with query api.
But you can add a relation for Order Line Items table to get your service (you will then be able to add a
with
in orderLineItems
).
For the final mapping shape, it will be in pure JS.Thank you as always @Raphaël M (@rphlmr) ⚡ , I decided to use raw sql to handle this feature instead