How to create component data in a lifecycle

System Information
  • Strapi Version: 4.4.5
  • Operating System: macos
  • Database: sqlite
  • Node Version: 14.21.1
  • NPM Version: 6
  • Yarn Version: 1.22

I want to add content to a repeatable component in my beforeUpdate hook. (adding a changed slug to a “previous slugs” list)
in v3, I could just push new data on the component array and it would save.

in v4, it doesn’t work like that. Component data now holds __pivot: and such. I do not know how to add new data to this. I’ve tried adding a component with the entityService first, and adding that result to the array. It seemed to work, but it has strange behavior that the next saves puts in two entries. I feel like there should be an easier way to go about this.

1 Like