clean up user
This commit is contained in:
@@ -12,7 +12,6 @@ export enum values {
|
||||
twitch_client_secret,
|
||||
}
|
||||
|
||||
const namesOfValues: string[] = ["", "pass", "omdb_key", "twitch_client_id", "twitch_client_secret"];
|
||||
|
||||
function getValue(name: values): string | undefined {
|
||||
try {
|
||||
@@ -26,31 +25,7 @@ function getValue(name: values): string | undefined {
|
||||
return;
|
||||
}
|
||||
|
||||
function updateValue(name: string, value: string): number {
|
||||
try {
|
||||
const result = pool.query("UPDATE userData SET value = ? WHERE name = ?").run(value, name);
|
||||
return result.changes;
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getAll(): UserD[] {
|
||||
try {
|
||||
const rows = pool.query("SELECT name, value FROM userData;").as(UserD).all();
|
||||
return rows;
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
export default {
|
||||
getValue,
|
||||
updateValue,
|
||||
getAll,
|
||||
namesOfValues
|
||||
getValue
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user