1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-28 14:38:52 +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 {
table: string,
tableAlias ?: string,
condition: string
}
export interface QueryInformation {
table: string,
tableAlias?: string,
joins ?: Array<JoinTableInfo>,
fields ?: Array<string>,
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
});
}