Users-permissions update error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where `t0`.`id` = ? Error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where `t0`.`id` =?

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 in strapi admin panel and after press save should check if some fields is changed I should change enum status of the user i`ve created in the
// src/extensions/users-permissions/content-types/user/index.js
const schema = require(’./schema.json’);
const lifecycles = require(’./lifecycles.js’);

module.exports = {
schema,
lifecycles
}

// src/extensions/users-permissions/content-types/strapi-server.js
module.exports = (plugin) => {

plugin.contentTypes.user = user;

return plugin;
}

// src/extensions/users-permissions/content-types/user/lifecycles.js
const axios = require(‘axios’);
async function getExchangeRate(currency) {
try {
const response = await axios.get(https://min-api.cryptocompare.com/data/price, {
params: {
fsym: currency,
tsyms: ‘USDT’,
api_key: CRYPTOCOMPARE_API_KEY,
},
});

if (response.data && response.data.USDT) {
  return response.data.USDT;
} else {
  console.error('Failed to get exchange rate for', currency);
  return null;
}

} catch (error) {
console.error(‘Error fetching exchange rate:’, error.message);
return null;
}
}

module.exports = {
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’],
populate: { category: true },
});

if (
  previousData.bitcoin_total === event.params.data.bitcoin_total &&
  previousData.ethereum_total === event.params.data.ethereum_total &&
  previousData.litecoin_total === event.params.data.litecoin_total &&
  previousData.dogecoin_total === event.params.data.dogecoin_total &&
  previousData.tetherTRC20_total === event.params.data.tetherTRC20_total &&
  previousData.tron_total === event.params.data.tron_total
){
  return;
}

const {
  bitcoin_total = 0,
  ethereum_total = 0,
  litecoin_total = 0,
  dogecoin_total = 0,
  tetherTRC20_total = 0,
  tron_total = 0,
  structural_turnover = 0
}  = event.params.data;

// Calculate the total amount in USDT based on the contribution amounts and exchange rates
const [
  tetherTRC20ExchangeRate,
  bitcoinExchangeRate,
  ethereumExchangeRate,
  litecoinExchangeRate,
  dogecoinExchangeRate,
  tronExchangeRate,
] = await Promise.all([
  getExchangeRate('USDT'),
  getExchangeRate('BTC'),
  getExchangeRate('ETH'),
  getExchangeRate('LTC'),
  getExchangeRate('DOGE'),
  getExchangeRate('TRX'),
]);

if (
  tetherTRC20ExchangeRate === null ||
  bitcoinExchangeRate === null ||
  ethereumExchangeRate === null ||
  litecoinExchangeRate === null ||
  dogecoinExchangeRate === null ||
  tronExchangeRate === null
) {
  console.error('Failed to fetch exchange rates. Unable to update user status.');
  return;
}

// Calculate the personal contribution in USDT
const personalContribution =
  bitcoin_total * bitcoinExchangeRate +
  ethereum_total * ethereumExchangeRate +
  litecoin_total * litecoinExchangeRate +
  dogecoin_total * dogecoinExchangeRate +
  tetherTRC20_total * tetherTRC20ExchangeRate +
  tron_total * tronExchangeRate;

let newStatus;

if (personalContribution >= 100000 ) {
  newStatus = 'Topleader';
} else if (personalContribution >= 50000 ) {
  newStatus = 'Professional';
} else if (personalContribution >= 25000 ) {
  newStatus = 'Brilliant';
} else if (personalContribution >= 10000 ) {
  newStatus = 'Platinum';
} else if (personalContribution >= 5000 ) {
  newStatus = 'Gold';
} else if (personalContribution >= 1500 ) {
  newStatus = 'Silver';
} else {
  newStatus = 'Ambition';
}

const user = (
  await strapi.entityService.findOne('plugin::users-permissions.user', event.params.data.id, {
    id: event.params.data.id,
  })
);
console.log('user findOne====>>>',user);

await strapi.entityService.update('plugin::users-permissions.user', user.id, {
  data: {
    status: newStatus,
    personal_deposit: personalContribution
  },
})

},
};

but receive an
error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where t0.id = ?
Error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where t0.id = ?

what did I do wrong?