Hello everyone,
1.
I have a LANDING PAGE model.
2.
As you can see this model has relation with PROGRAMMES.
This PROGRAMME relation has few components and repeatable components inside of it which work out of the box.
The problem arose when I realized that the nested relations inside of programmes don’t show up, so I followed @derrickmehaffy solution from here
As you can see below on the image, this fixed the deeply nested relations.
This was the code that I used to fix this:
let populate = [
"programmes",
"programmes.locations",
"programmes.certification",
"programmes.study_modes",
"programmes.degree_level",
"programmes.verticals",
];
let entity = await strapi.services["landing-page"].findOne(
ctx.query,
populate
);
let data = sanitizeEntity(entity, { model: strapi.models["landing-page"] });
return data;
},
PERFECT!
3.
BUT THERE IS A CATCH
Now, where the issue happened? When I used the populate method all of the components and repeatable components that were there before - inside of the relation with the programme, simply disappeared from the object.
As you can see below are the components that vanished after populate.
4.
I have tried to do something like this:
let populate = [
"programmes",
"programmes.locations",
"programmes.certification",
"programmes.study_modes",
"programmes.degree_level",
"programmes.verticals",
"programmes.pSpecialisations",
"programmes.ctaButton",
"programmes.overviewSection",
];
let entity = await strapi.services["landing-page"].findOne(
ctx.query,
populate
);
let data = sanitizeEntity(entity, { model: strapi.models["landing-page"] });
return data;
},
But it didn’t work, since as from what I understood in @DMehaffy comment is that populate is only working for relational fields.
Does anyone have an idea how to fix this?