From 57f96241f1586cbcb573024c344e1e9c1338cb21 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 29 Jul 2022 20:20:47 +0100 Subject: [PATCH] filters implemented --- CommonServer/API/BaseAPI.ts | 1 + CommonServer/Services/DatabaseService.ts | 1 + CommonServer/Types/Database/QueryHelper.ts | 2 +- CommonServer/Utils/StartServer.ts | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CommonServer/API/BaseAPI.ts b/CommonServer/API/BaseAPI.ts index b887141c60..adc70cd977 100644 --- a/CommonServer/API/BaseAPI.ts +++ b/CommonServer/API/BaseAPI.ts @@ -183,6 +183,7 @@ export default class BaseAPI< query = JSONFunctions.deserialize( req.body['query'] ) as Query; + debugger; select = JSONFunctions.deserialize( req.body['select'] ) as Select; diff --git a/CommonServer/Services/DatabaseService.ts b/CommonServer/Services/DatabaseService.ts index 3bcb061118..62cb036dd8 100644 --- a/CommonServer/Services/DatabaseService.ts +++ b/CommonServer/Services/DatabaseService.ts @@ -868,6 +868,7 @@ class DatabaseService { (query[key] as ObjectID).toString() as any ) as any; } else if (query[key] && query[key] instanceof Search) { + debugger; query[key] = QueryHelper.search( (query[key] as Search).toString() as any ) as any; diff --git a/CommonServer/Types/Database/QueryHelper.ts b/CommonServer/Types/Database/QueryHelper.ts index 8791223e50..5776e6f865 100644 --- a/CommonServer/Types/Database/QueryHelper.ts +++ b/CommonServer/Types/Database/QueryHelper.ts @@ -21,7 +21,7 @@ export default class QueryHelper { const rid: string = Text.generateRandomText(10); return Raw( (alias: string) => { - return `LOWER(${alias}) = :${rid}`; + return `LOWER(${alias}) LIKE (:${rid})`; }, { [rid]: `%${name}%`, diff --git a/CommonServer/Utils/StartServer.ts b/CommonServer/Utils/StartServer.ts index a37789e881..7a3a122833 100644 --- a/CommonServer/Utils/StartServer.ts +++ b/CommonServer/Utils/StartServer.ts @@ -22,6 +22,7 @@ import LocalCache from '../Infrastructure/LocalCache'; import Exception from 'Common/Types/Exception/Exception'; import ObjectID from 'Common/Types/ObjectID'; import StatusCode from 'Common/Types/API/StatusCode'; +import Typeof from 'Common/Types/Typeof'; // import OpenTelemetrySDK from "./OpenTelemetry"; const app: ExpressApplication = Express.getExpressApp();