query print
This commit is contained in:
parent
f63c0cf6d0
commit
155e702863
2 changed files with 11 additions and 11 deletions
|
@ -29,8 +29,8 @@ export class DB {
|
||||||
|
|
||||||
this.name = database;
|
this.name = database;
|
||||||
}
|
}
|
||||||
async query(query: Query) {
|
async query(query: Query, printQuery = false) {
|
||||||
console.log(query);
|
if(printQuery)console.log(query);
|
||||||
if (this.type == dbType.mariadb) return await this.mariaPool.query(query);
|
if (this.type == dbType.mariadb) return await this.mariaPool.query(query);
|
||||||
/*else if (this.type == dbType.postgres) {
|
/*else if (this.type == dbType.postgres) {
|
||||||
let res = await this.pgPool.query(query.sql, query.values);
|
let res = await this.pgPool.query(query.sql, query.values);
|
||||||
|
|
18
src/query.ts
18
src/query.ts
|
@ -49,7 +49,7 @@ export class QueryBuilder {
|
||||||
this.list.push(...qb.list);
|
this.list.push(...qb.list);
|
||||||
}
|
}
|
||||||
appendEnding(qb: QueryBuilder) {
|
appendEnding(qb: QueryBuilder) {
|
||||||
if(qb.isEmpty()) return;
|
if (qb.isEmpty()) return;
|
||||||
this.append(qb);
|
this.append(qb);
|
||||||
this.list.push([false, ";"]);
|
this.list.push([false, ";"]);
|
||||||
}
|
}
|
||||||
|
@ -96,11 +96,11 @@ export class selectQuery {
|
||||||
return handler.querys.select(handler, this);
|
return handler.querys.select(handler, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
async query(db: DB) {
|
async query(db: DB, printQuery = false) {
|
||||||
const handler = db.getHandler();
|
const handler = db.getHandler();
|
||||||
const builder = this.serialize(handler);
|
const builder = this.serialize(handler);
|
||||||
const s = handler.builders.query(builder);
|
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);
|
return db.getHandler().responses.readResponse(readResp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,11 +134,11 @@ export class insertQuery {
|
||||||
serialize(handler: Handler): QueryBuilder {
|
serialize(handler: Handler): QueryBuilder {
|
||||||
return handler.querys.insert(handler, this);
|
return handler.querys.insert(handler, this);
|
||||||
}
|
}
|
||||||
async query(db: DB) {
|
async query(db: DB, printQuery = false) {
|
||||||
const handler = db.getHandler();
|
const handler = db.getHandler();
|
||||||
const builder = this.serialize(handler);
|
const builder = this.serialize(handler);
|
||||||
const s = handler.builders.query(builder);
|
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);
|
return db.getHandler().responses.insertResponse(readResp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,11 +163,11 @@ export class updateQuery {
|
||||||
serialize(handler: Handler): QueryBuilder {
|
serialize(handler: Handler): QueryBuilder {
|
||||||
return handler.querys.update(handler, this);
|
return handler.querys.update(handler, this);
|
||||||
}
|
}
|
||||||
async query(db: DB) {
|
async query(db: DB, printQuery = false) {
|
||||||
const handler = db.getHandler();
|
const handler = db.getHandler();
|
||||||
const builder = this.serialize(handler);
|
const builder = this.serialize(handler);
|
||||||
const s = handler.builders.query(builder);
|
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);
|
return db.getHandler().responses.writeResponse(readResp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,11 +185,11 @@ export class removeQuery {
|
||||||
serialize(handler: Handler): QueryBuilder {
|
serialize(handler: Handler): QueryBuilder {
|
||||||
return handler.querys.remove(handler, this);
|
return handler.querys.remove(handler, this);
|
||||||
}
|
}
|
||||||
async query(db: DB) {
|
async query(db: DB, printQuery = false) {
|
||||||
const handler = db.getHandler();
|
const handler = db.getHandler();
|
||||||
const builder = this.serialize(handler);
|
const builder = this.serialize(handler);
|
||||||
const s = handler.builders.query(builder);
|
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);
|
return db.getHandler().responses.writeResponse(readResp);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue