Hi, I am wanting to edit a user field on Strapi during a model life cycle.
If a certain value changes in my model I want to update the owner’s (user) data. I have the lifecycle working as I want but can’t figure out how to update the user through the model file. Any help on how I can do this or if this is possible from model lifecycles?
module.exports = {
lifecycles: {
async afterUpdate(result, params, data) {
//model was updated, now you can query the user's model to update it also.
await strapi.query('user', 'users-permissions').update({ id:data.user }, {amount:10});
//update function accepts two parameters, first one is used to identify the user and the second one is the Data that you want to update.
},
},
};