From c3d38a0fae5238f320a681a756dfc4098299d6c2 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Mon, 23 Sep 2024 18:55:05 +0300 Subject: [PATCH] Fix relation matching --- src/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index 9d84a53..46eea78 100644 --- a/src/utils.js +++ b/src/utils.js @@ -49,11 +49,12 @@ export const normalizeResponse = (items = [], relations = []) => ...item, ...Object.fromEntries(relations.map(([field, collection, idField]) => { const key = item[idField]; - const fn = Array.isArray(key) ? 'filter' : 'find'; return [ field, - collection[fn](item => item.id === key), + Array.isArray(key) ? + collection.filter(item => key.includes(item.id)) : + collection.find(item => item.id === key), ]; })), })