moved db name #12
1 changed files with 8 additions and 11 deletions
11
src/db.ts
11
src/db.ts
|
@ -11,19 +11,16 @@ import { insertResponse, readResponse, writeResponse, singleResponse } from "./r
|
|||
export class DB {
|
||||
tables: Table[] = [];
|
||||
handler!: Handler;
|
||||
name: string;
|
||||
name!: string;
|
||||
type!: dbType;
|
||||
mariaPool!: mariadb.Pool;
|
||||
private connected = false;
|
||||
//pgPool!: pg.Pool;
|
||||
constructor(database: string) {
|
||||
this.name = database;
|
||||
}
|
||||
connect({ host, user, password, port = 3306, connectionLimit = 5, databaseType = dbType.mariadb }: { host: string, user: string, password: string, port?: number, connectionLimit?: number, databaseType?: dbType }) {
|
||||
connect({ host, user, password, database, port = 3306, connectionLimit = 5, databaseType = dbType.mariadb }: { host: string, user: string, password: string, database: string, port?: number, connectionLimit?: number, databaseType?: dbType }) {
|
||||
this.connected = true;
|
||||
this.type = databaseType;
|
||||
if (databaseType == dbType.mariadb) {
|
||||
this.mariaPool = mariadb.createPool({ host, user, password, port, database: this.name, connectionLimit, multipleStatements: true });
|
||||
this.mariaPool = mariadb.createPool({ host, user, password, port, database, connectionLimit, multipleStatements: true });
|
||||
this.handler = new Handler(this);
|
||||
}
|
||||
/*else if (databaseType == dbType.postgres) {
|
||||
|
@ -32,7 +29,7 @@ export class DB {
|
|||
}*/
|
||||
else throw new Error("Unsuported Database type!");
|
||||
|
||||
|
||||
this.name = database;
|
||||
}
|
||||
async query(query: Query, printQuery = false) {
|
||||
if (!this.connected) throw new Error("Not connected yet!");
|
||||
|
|
Loading…
Reference in a new issue