Strapi V4 lifecycles hooks

System Information
  • **Strapi Version4.0.0.:
  • **Operating Systemwin10:
  • **Databasesqlite:
  • **Node Version14:
  • **NPM Version6.8:
  • Yarn Version:

Hello All I’m trying to make a lifecycle hook “beforeUpdate” on collection type that has repeatable component “calendar” that is using component “day” with multiple strings, bools and one relationship.

Collection Type: calendar
consists of:

1. name - type text
2. calendar - repeatable component
3. 3 relationships

* repeatable component has:
1. 2-3 booleans
2. 2-3 integers
3. 1 relationship

I know that in new strapi V4 we need to populate data if it is in components or relationship, is there some easy way to do it from lifecycle or i need to use

const entry = await strapi.entityService.findMany('api::calendar.calendar',{populate:{
            calendar: true,
            unit:true,
            reservations:true
        }});

lifecycle hook

beforeUpdate: async (event) => {

    console.log(event);

    const { data, where, populate } = event.params;

    console.log(data.calendar);

  },

2 Likes

Hello!

Have you found answer to that?

I made additional collection type:

First one is calendar and it has relation one to many on collection type calendar_day

Its not ideal but its working