System Information
- Strapi Version: 4.5.0
- Operating System: MacOS
- Database: sqlite/postgres
- Node Version: v16.14.0
- NPM Version: 8.3.1
- Yarn Version: 1.22.17
Does anyone know how to get previous component data for a collection-type in lifecycle hook in strapi v4 before the component data gets updated? Because the event.params.data will return a useless object like this for a component, which doesn’t give me the component data I need
[
{
id: 44,
__pivot: {
field: 'kickoutFlag',
component_type: 'outcome-component.kickout-flag'
}
}
]
I tried getting the previous component data using 4 different methods in the beforeUpdate lifecycle hook, but in all 4 cases it returns me the updated component data rather than the previous component data before it gets updated. I listed the 4 methods I used and attached a screenshot of what I tried.
My collection-type is called tass and my component is called kickoutFlag just for some context.
Please can anyone tell me how I can get previous component data before it is updated in a lifecycle hook?
- strapi.requestContext.get();
- Using entityService api
- using strapi.query
- using strapi.db.query