From 6ad4375b2a9b7749f8326474bf145b6ee8baa6ec Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 23 Nov 2019 18:39:58 +0100 Subject: [PATCH] Can join tables --- src/helpers/DatabaseHelper.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/helpers/DatabaseHelper.ts b/src/helpers/DatabaseHelper.ts index 299d0ca..1f62f6a 100644 --- a/src/helpers/DatabaseHelper.ts +++ b/src/helpers/DatabaseHelper.ts @@ -7,8 +7,14 @@ import { conf } from "./ConfigHelper"; * @author Pierre HUBERT */ +export interface JoinTableInfo { + table: string, + condition: string +} + export interface QueryInformation { table: string, + joins ?: Array, fields ?: Array, where ?: Object, order ?: string, @@ -66,6 +72,15 @@ export class DatabaseHelper { request += info.fields ? info.fields.join(",") : "*"; request += " FROM " + info.table; + + // Joins condition + if(info.joins) { + info.joins.forEach(join => { + request += " JOIN " + join.table + " ON " + join.condition + }); + } + + let args = []; // Add where arguments