diff --git a/src/db.ts b/src/db.ts index 0d2ab04..860e3aa 100644 --- a/src/db.ts +++ b/src/db.ts @@ -29,8 +29,8 @@ export class DB { this.name = database; } - async query(query: Query) { - console.log(query); + async query(query: Query, printQuery = false) { + if(printQuery)console.log(query); if (this.type == dbType.mariadb) return await this.mariaPool.query(query); /*else if (this.type == dbType.postgres) { let res = await this.pgPool.query(query.sql, query.values); diff --git a/src/query.ts b/src/query.ts index a69d5ef..f5202c7 100644 --- a/src/query.ts +++ b/src/query.ts @@ -49,7 +49,7 @@ export class QueryBuilder { this.list.push(...qb.list); } appendEnding(qb: QueryBuilder) { - if(qb.isEmpty()) return; + if (qb.isEmpty()) return; this.append(qb); this.list.push([false, ";"]); } @@ -96,11 +96,11 @@ export class selectQuery { return handler.querys.select(handler, this); } - async query(db: DB) { + async query(db: DB, printQuery = false) { const handler = db.getHandler(); const builder = this.serialize(handler); const s = handler.builders.query(builder); - let readResp = await db.query(s); + let readResp = await db.query(s, printQuery); return db.getHandler().responses.readResponse(readResp); } } @@ -134,11 +134,11 @@ export class insertQuery { serialize(handler: Handler): QueryBuilder { return handler.querys.insert(handler, this); } - async query(db: DB) { + async query(db: DB, printQuery = false) { const handler = db.getHandler(); const builder = this.serialize(handler); const s = handler.builders.query(builder); - let readResp = await db.query(s); + let readResp = await db.query(s, printQuery); return db.getHandler().responses.insertResponse(readResp); } } @@ -163,11 +163,11 @@ export class updateQuery { serialize(handler: Handler): QueryBuilder { return handler.querys.update(handler, this); } - async query(db: DB) { + async query(db: DB, printQuery = false) { const handler = db.getHandler(); const builder = this.serialize(handler); const s = handler.builders.query(builder); - let readResp = await db.query(s); + let readResp = await db.query(s, printQuery); return db.getHandler().responses.writeResponse(readResp); } } @@ -185,11 +185,11 @@ export class removeQuery { serialize(handler: Handler): QueryBuilder { return handler.querys.remove(handler, this); } - async query(db: DB) { + async query(db: DB, printQuery = false) { const handler = db.getHandler(); const builder = this.serialize(handler); const s = handler.builders.query(builder); - let readResp = await db.query(s); + let readResp = await db.query(s, printQuery); return db.getHandler().responses.writeResponse(readResp); } } \ No newline at end of file