clean up user
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
node_modules/
|
||||
output/
|
||||
*.sqlite
|
||||
*.sqlite
|
||||
.vscode
|
||||
@@ -15,7 +15,8 @@ interface omdbRes {
|
||||
function fromStringToTable(input: string | string[]): (Table | undefined) {
|
||||
var value = "";
|
||||
if (Array.isArray(input)) {
|
||||
value = input[0];
|
||||
if (input.length > 0)
|
||||
value = input[0];
|
||||
}
|
||||
else {
|
||||
value = input;
|
||||
|
||||
@@ -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