When deleting a record through the ng-bot, all data is deleted, but I need that when I clicked the "Delete" button, the record that was displayed to the user was deleted, if anyone came across I ask for help !!!

Below is a sample code:

bot.on('callback_query', query => { client.query(`select * from person_list`, (err,res) => { if(err) console.log(err); let jsonString = JSON.stringify(res.rows); let jsonObj = JSON.parse(jsonString); let arr = []; for(let i in jsonObj){ arr.push(jsonObj[i]); } if (query.data === 'delete'){ client.query(`delete from person_list where id=${arr[i].id}`, (err,res) => { if(err) console.log(err); bot.answerCallbackQuery(query.from.id, text=`Пользователь с ID: ${arr[i].id} успешно удален`); }) } if(query.data === 'update') { bot.sendMessage(query.from.id, "Изменение данных...", opts); } else if (query.data === 'person_fio'){ client.query('INSERT INTO person_list(person_fio) values($1) RETURNING *'); } else if(query.data === 'person_position'){ client.query('INSERT INTO person_list(person_position) values($1) RETURNING *') } else if(query.data === 'address_id'){ client.query('INSERT INTO person_list(person_address_id) values($1) RETURNING *') } else if(query.data === 'department'){ client.query('INSERT INTO person_list(department) values($1) RETURNING *') } }); }); 
  • Please do not ask the same question several times. If you want to add parts - edit the existing one - PashaPash

0