I’m currently working on a project which has three tables,
- Consumers
2)Consumer_orders
3)Consumer_order_items
The Consumers primary key id is fk to Consumer_orders with column name consumer_id.
The Consumer_orders pk id is fk to Consumer_order_items with column name consumer_order_id.
So I need to create a Get API with showing who paid for the order( paid is a boolean column added in Consumers),by that in get API it will show all users in db who have paid for the order
showing:
the consumer name,consumer orders,consumer order items
I’m stuck.I dont know how to fetch the data from the 3rd table to which no relation created from 1st table
So maybe you can do something like
Consumers.findAll({
where: { paid: true },
include: { all: true, nested: true }
});