mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 14:59:22 +00:00
Can join tables
This commit is contained in:
parent
517e75215b
commit
6ad4375b2a
@ -7,8 +7,14 @@ import { conf } from "./ConfigHelper";
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export interface JoinTableInfo {
|
||||||
|
table: string,
|
||||||
|
condition: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface QueryInformation {
|
export interface QueryInformation {
|
||||||
table: string,
|
table: string,
|
||||||
|
joins ?: Array<JoinTableInfo>,
|
||||||
fields ?: Array<String>,
|
fields ?: Array<String>,
|
||||||
where ?: Object,
|
where ?: Object,
|
||||||
order ?: string,
|
order ?: string,
|
||||||
@ -66,6 +72,15 @@ export class DatabaseHelper {
|
|||||||
request += info.fields ? info.fields.join(",") : "*";
|
request += info.fields ? info.fields.join(",") : "*";
|
||||||
|
|
||||||
request += " FROM " + info.table;
|
request += " FROM " + info.table;
|
||||||
|
|
||||||
|
// Joins condition
|
||||||
|
if(info.joins) {
|
||||||
|
info.joins.forEach(join => {
|
||||||
|
request += " JOIN " + join.table + " ON " + join.condition
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let args = [];
|
let args = [];
|
||||||
|
|
||||||
// Add where arguments
|
// Add where arguments
|
||||||
|
Loading…
Reference in New Issue
Block a user