From 6426b2e27527643dbf9bc83c11667325b8a9102a Mon Sep 17 00:00:00 2001 From: adhimrahman Date: Tue, 7 May 2024 15:11:15 +0800 Subject: [PATCH] add: deleteMyUser and deleteMyArtist --- utils/deleteDatas.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 utils/deleteDatas.js diff --git a/utils/deleteDatas.js b/utils/deleteDatas.js new file mode 100644 index 0000000..695769c --- /dev/null +++ b/utils/deleteDatas.js @@ -0,0 +1,30 @@ +const mysql = require('mysql'); +const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'spotitip' }); + +async function deleteMyUser(userId) { + return new Promise((resolve, reject) => { + const sql = 'DELETE FROM user WHERE id= ?'; + connection.query(sql, [userId], (err, results) => { + if (err) { + reject(err); + } else { + resolve(results); + } + }); + }); +} + +async function deleteMyArtist(artistId) { + return new Promise((resolve, reject) => { + const sql = 'DELETE FROM artist WHERE id= ?'; + connection.query(sql, [artistId], (err, results) => { + if (err) { + reject(err); + } else { + resolve(results); + } + }); + }); +} + +module.exports = { deleteMyUser, deleteMyArtist } \ No newline at end of file