trying to achieve nested lists of joined table records:
For example:
const expectedList = [
{
id: 1,
username: "test",
orders: [
{ id: 1, product_id: 2, etc: "" },
{ id: 2, product_id: 3, etc: "" }
]
}
];
const actualList = [
{
id: 1,
username: "test",
orders: { id: 1, product_id: 2, etc: "" }
},
{
id: 1,
username: "test",
orders: { id: 2, product_id: 3, etc: "" }
}
];
Is there a way to achieve expected list without iterating over the actualList?
You need at least iterate one, even though you use some liberary function, it will iterate under the hood.
Обсуждают сегодня