aboutsummaryrefslogtreecommitdiff
path: root/src/db/DBController.ts
diff options
context:
space:
mode:
authorMarvin Borner2020-07-18 20:09:03 +0200
committerMarvin Borner2020-07-18 20:09:03 +0200
commit5ad4683e2e59ea1d00558945872089bebea1c2b1 (patch)
tree5292033dc32b089f6d7a0775162bf24a5683acd1 /src/db/DBController.ts
parent26f84c953f9fbb9c5afb4f8a063759d272256f36 (diff)
Fixed abc submodule
Diffstat (limited to 'src/db/DBController.ts')
-rw-r--r--src/db/DBController.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/db/DBController.ts b/src/db/DBController.ts
index 274e446..4188bd1 100644
--- a/src/db/DBController.ts
+++ b/src/db/DBController.ts
@@ -5,7 +5,7 @@ export default class DBController {
private client?: Client;
async init() {
- this.client = await this.connect();
+ await this.connect();
try {
const sql = await readFileStr("./src/db/tables.sql");
const queries = sql.split(";");
@@ -18,9 +18,9 @@ export default class DBController {
}
}
- async connect(): Promise<Client> {
+ async connect() {
try {
- return await new Client().connect({
+ this.client = await new Client().connect({
hostname: Deno.env.get("DBHost"),
username: Deno.env.get("DBUser"),
db: Deno.env.get("DBName"),
@@ -46,12 +46,13 @@ export default class DBController {
if (!this.client) throw Error("Database isn't initialized yet!");
try {
- await this.client.execute(query, params);
+ return await this.client.execute(query, params);
} catch (e) {
throw e;
}
}
+ // deno-lint-ignore no-explicit-any
async execute_multiple(queries: any[][]) {
if (!this.client) throw Error("Database isn't initialized yet!");