From 6e536d850cb70054d01adcf76870b81d4e684433 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Fri, 23 Jul 2021 22:19:54 -0600 Subject: [PATCH] lib.userData: add delete --- src/lib/userData.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib/userData.js b/src/lib/userData.js index 2b633af..ccece90 100644 --- a/src/lib/userData.js +++ b/src/lib/userData.js @@ -39,7 +39,26 @@ function getUserData(id, key, fallback = null) { }); } +function deleteUserData(id, key) { + return new Promise((resolve, reject) => { + hf.database.run( + "DELETE FROM user_data WHERE key = $key", + { + $key: `${id}[${key}]`, + }, + (err) => { + if (err == null) { + resolve(true); + } else { + reject(err); + } + } + ); + }); +} + module.exports = { setUserData, getUserData, + deleteUserData, };