Fix relation matching
This commit is contained in:
parent
4128e0e68a
commit
c3d38a0fae
|
@ -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),
|
||||
];
|
||||
})),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue