System Information
- Strapi Version: 4
- Operating System: Mac OS
- Database: Postgres
- Node Version: 16
I’m trying to update a text field with relation title in a dynamic component using beforeUpdate. Here is my function.
async beforeUpdate(event) {
const { where } = event.params;
const id = where.id
const location = await strapi.entityService.findOne("api::menu.menu", id,{
populate: 'deep',
});
const local = location.editLocation
local.map((item) => {
item.storeTitle = item.location.title
return item
})
},
I’m guessing entity service is the wrong way to go. The data I want is updated via console.log but the actual database stays the same. The .update()
does not seem to have a clear way for me to loop through the components nor use populate=deep
as I use above.
Does anyone have any recommendations or confirm what I am doing is not possible? I admit I am a noob in this area. I am trying to update these components since they don’t have their own life cycle hooks. Also tried several solutions to make the component display name be the relationship title but have had no luck.