Lifecycle hooks for Components
Hi everyone! I think it would be very useful to have lifecycle hooks for Components, just as it is today for Collection Types.
Do this, and work a little bit :)
Agree, I really really need my previous component data to be visible in the beforeUpdate lifecycle before it gets updated. Strapi is almost useless for the feature my company needs (viewing change log and version control of data updates) without this feature since 90% of our data is component based. Would anyone know an alternative solution to how I could get pre-updated component data before it updates? And then compare the old vs. updated component data?
Sem Limi: I saw an idea to fetch the data from old record, but after I tried that, I get the same data for components - since components are saved before lifecycle events are even fired (as far as I understand it).
Nitara: If you use a before hook it should be fired before the components are saved if that is not the cease you could add a middleware that fires before you even call the lifecycle
Boegie19: Yes, I am using beforeCreate/beforeUpdate and data there contains just IDs of records in components - but I can fetch that with a bit of additional code. The issue is that fetched old record and data sent to lifecycle method is the same (for components). I will check out this middleware method - did not use those until now in Strapi, but sounds like a feasible idea, with probably some other gotchas, but well, that is programming :D Thank you!
Any luck guys? this is a much needed solution.
yes it would be great, I've been stuck to find a solution for this matter
Or at least make component data visible in before... lifecycle hooks of content types
Agreed! This would be extremely useful.