System Information
- strapi - 4.11.7:
- macOS:
- ** sqlite**:
- ** node - v16.13.0**:
- npm - 8.1.0:
- yarn - 1.13.0:
I need to update user model in strapi admin panel and after press save button should check if some fields (e.g. bitcoin_total) is changed then it should change status field in the user model
when I trying run the code below I have Infiniti loop
'use strict';
module.exports = {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
* This gives you an opportunity to extend code.
*/
register(/*{ strapi }*/) {},
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
bootstrap({ strapi }) {
strapi.db.lifecycles.subscribe({
models: ["plugin::users-permissions.user"],
beforeUpdate: async (event) => {
const previousData = await strapi.entityService.findOne(
"plugin::users-permissions.user",
event.params.data.id,
{
fields: [
"bitcoin_total",
"ethereum_total",
"litecoin_total",
"dogecoin_total",
"tetherTRC20_total",
"tron_total",
"status",
],
},
);
if (previousData.bitcoin_total !== event.params.data.bitcoin_total) {
await strapi.entityService.update('plugin::users-permissions.user', event.params.data.id, {
data: {
id: event.params.data.id,
status: 'Gold',
},
})
}
},
});
},
};
please give me a hint