From 7d6979e0960625fcd7040f94ff5ed2924de39bdc Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 7 Dec 2019 11:50:59 +0100 Subject: [PATCH] Add tables aliases support --- src/helpers/DatabaseHelper.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helpers/DatabaseHelper.ts b/src/helpers/DatabaseHelper.ts index d7d37aa..b0d933a 100644 --- a/src/helpers/DatabaseHelper.ts +++ b/src/helpers/DatabaseHelper.ts @@ -9,11 +9,13 @@ import { conf } from "./ConfigHelper"; export interface JoinTableInfo { table: string, + tableAlias ?: string, condition: string } export interface QueryInformation { table: string, + tableAlias?: string, joins ?: Array, fields ?: Array, where ?: Object, @@ -88,10 +90,13 @@ export class DatabaseHelper { request += " FROM " + info.table; + if(info.tableAlias) + request += " " + info.tableAlias + " "; + // Joins condition if(info.joins) { info.joins.forEach(join => { - request += " JOIN " + join.table + " ON " + join.condition + request += " JOIN " + join.table + (join.tableAlias ? " " + join.tableAlias : "") + " ON " + join.condition }); }