I have a Node.JS project and am using sequelize as the ORM. I would like to run a query where I get all of my orders grouped by the status. So I would get for example an object with 5 keys (given that I have 5 different statuses). And in each key there would be an array with all orders that have that status.
Example of object:
{
"Done": [{id:1, item: "bag"}, {id:2, item: "purse"}],
"Processing": [{id:3, item: "bag"}, {id:4, item: "purse"}],
"Pending": [{id:5, item: "bag"}, {id:6, item: "purse"}]
}
Is this possible in any way or I need to get all possible statuses and just run the same number of queries each time changing the where clause?
Thanks