1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 13:29:22 +00:00

Add tables aliases support

This commit is contained in:
Pierre HUBERT 2019-12-07 11:50:59 +01:00
parent af97216c13
commit 7d6979e096

View File

@ -9,11 +9,13 @@ import { conf } from "./ConfigHelper";
export interface JoinTableInfo { export interface JoinTableInfo {
table: string, table: string,
tableAlias ?: string,
condition: string condition: string
} }
export interface QueryInformation { export interface QueryInformation {
table: string, table: string,
tableAlias?: string,
joins ?: Array<JoinTableInfo>, joins ?: Array<JoinTableInfo>,
fields ?: Array<string>, fields ?: Array<string>,
where ?: Object, where ?: Object,
@ -88,10 +90,13 @@ export class DatabaseHelper {
request += " FROM " + info.table; request += " FROM " + info.table;
if(info.tableAlias)
request += " " + info.tableAlias + " ";
// Joins condition // Joins condition
if(info.joins) { if(info.joins) {
info.joins.forEach(join => { info.joins.forEach(join => {
request += " JOIN " + join.table + " ON " + join.condition request += " JOIN " + join.table + (join.tableAlias ? " " + join.tableAlias : "") + " ON " + join.condition
}); });
} }