mirror of
https://github.com/strapi/strapi.git
synced 2025-12-13 16:08:11 +00:00
normalizeRelations: Return empty array as fallback
This commit is contained in:
parent
6d1642d713
commit
3e90c71ead
@ -6,16 +6,12 @@ export const normalizeRelations = (
|
|||||||
relations,
|
relations,
|
||||||
{ modifiedData = {}, shouldAddLink = false, mainFieldName, targetModel }
|
{ modifiedData = {}, shouldAddLink = false, mainFieldName, targetModel }
|
||||||
) => {
|
) => {
|
||||||
// TODO
|
|
||||||
if (!relations?.data?.pages) {
|
|
||||||
return relations;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...relations,
|
...relations,
|
||||||
data: {
|
data: {
|
||||||
pages: relations.data.pages
|
pages:
|
||||||
.map((page) => [
|
relations?.data?.pages
|
||||||
|
?.map((page) => [
|
||||||
...[...page.results, ...(modifiedData?.connect ?? [])]
|
...[...page.results, ...(modifiedData?.connect ?? [])]
|
||||||
.map((relation) => {
|
.map((relation) => {
|
||||||
const nextRelation = { ...relation };
|
const nextRelation = { ...relation };
|
||||||
@ -42,8 +38,8 @@ export const normalizeRelations = (
|
|||||||
})
|
})
|
||||||
.filter(Boolean),
|
.filter(Boolean),
|
||||||
])
|
])
|
||||||
.filter((page) => page.length > 0)
|
?.filter((page) => page.length > 0)
|
||||||
.reverse(),
|
?.reverse() ?? [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user