OK. There is another way. You can customize life cycles
As I understand it this way is preferable.
Declarative sample
./src/api/todo/content-types/todo/lifecycles.ts is the declare file path
export default {
async beforeCreate(event) {
const ctx = await strapi.requestContext.get();
event.params.data.user = ctx.state.user; // Add User from the default plugin User & Permissions to the Todo entity
event.params.data.state = { id: 1 }; // Add default State to the Todo entity
},
};
Thanks for the great comunity Strapi — русскоговорящее сообщество