From 52a1f34162228ed3f9e826dd845cb1eeb5b4971c Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Mon, 16 Dec 2024 17:41:26 +0100 Subject: [PATCH] state pass --- src/controller/admin/queryBuilderController.ts | 6 ++++-- src/type/dynamicQueries.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/controller/admin/queryBuilderController.ts b/src/controller/admin/queryBuilderController.ts index fdf93a1..312de93 100644 --- a/src/controller/admin/queryBuilderController.ts +++ b/src/controller/admin/queryBuilderController.ts @@ -41,14 +41,16 @@ export async function executeQuery(req: Request, res: Response): Promise { let [rows, total] = await DynamicQueryBuilder.buildQuery(query, offset, count).getManyAndCount(); res.json({ + stats: "success", rows: rows, total: total, offset: offset, count: count, }); } catch (error) { - res.status(500).send({ - json: error.sql, + res.json({ + stats: "error", + sql: error.sql, code: error.code, msg: error.sqlMessage, }); diff --git a/src/type/dynamicQueries.ts b/src/type/dynamicQueries.ts index 5e69094..9e1f046 100644 --- a/src/type/dynamicQueries.ts +++ b/src/type/dynamicQueries.ts @@ -43,7 +43,9 @@ export type WhereOperation = | "notNull" // Is not null | "between" // Is between | "startsWith" // Starts with - | "endsWith"; // Ends with + | "endsWith" // Ends with + | "timespanEq"; // Date before x years (YYYY-01-01 YYYY-12-31) +// TODO: age between | age equals | age greater | age smaller export type OrderByStructure = { column: string;