oldRows = [
{ id: 1, service_pack_id: "36", card_product_id: '123' },
{ id: 2, service_pack_id: "40", card_product_id: '124' },
{ id: 3, service_pack_id: "36", card_product_id: '125'},
{ id: 4, service_pack_id: "40", card_product_id: null},
{ id: 5, service_pack_id: null, card_product_id: null}
];
измененный oldRows = [
{ id: 1, service_pack_id: '36', card_product_ids: ['123', '124'] },
{ id: 2, service_pack_id: '40', card_product_ids: ['125'] }
]
.filter() и лукап сета/массива с нужными айдишниками?
oldRows = oldRows.filter(({ id }) => [1, 2].includes(id))
Обсуждают сегодня