mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Add tables aliases support
This commit is contained in:
parent
af97216c13
commit
7d6979e096
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user