clean up user
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
output/
|
output/
|
||||||
*.sqlite
|
*.sqlite
|
||||||
|
.vscode
|
||||||
@@ -15,6 +15,7 @@ interface omdbRes {
|
|||||||
function fromStringToTable(input: string | string[]): (Table | undefined) {
|
function fromStringToTable(input: string | string[]): (Table | undefined) {
|
||||||
var value = "";
|
var value = "";
|
||||||
if (Array.isArray(input)) {
|
if (Array.isArray(input)) {
|
||||||
|
if (input.length > 0)
|
||||||
value = input[0];
|
value = input[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ export enum values {
|
|||||||
twitch_client_secret,
|
twitch_client_secret,
|
||||||
}
|
}
|
||||||
|
|
||||||
const namesOfValues: string[] = ["", "pass", "omdb_key", "twitch_client_id", "twitch_client_secret"];
|
|
||||||
|
|
||||||
function getValue(name: values): string | undefined {
|
function getValue(name: values): string | undefined {
|
||||||
try {
|
try {
|
||||||
@@ -26,31 +25,7 @@ function getValue(name: values): string | undefined {
|
|||||||
return;
|
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 {
|
export default {
|
||||||
getValue,
|
getValue
|
||||||
updateValue,
|
|
||||||
getAll,
|
|
||||||
namesOfValues
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user