Fix relation matching
This commit is contained in:
parent
4128e0e68a
commit
c3d38a0fae
|
@ -49,11 +49,12 @@ export const normalizeResponse = (items = [], relations = []) =>
|
||||||
...item,
|
...item,
|
||||||
...Object.fromEntries(relations.map(([field, collection, idField]) => {
|
...Object.fromEntries(relations.map(([field, collection, idField]) => {
|
||||||
const key = item[idField];
|
const key = item[idField];
|
||||||
const fn = Array.isArray(key) ? 'filter' : 'find';
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
field,
|
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