From d8f296913e27b8c4a4c725206f92b3a054a8c5cf Mon Sep 17 00:00:00 2001 From: lostfields Date: Wed, 12 Jun 2024 21:16:31 +0200 Subject: [PATCH] chore: make query optional --- package-lock.json | 2 +- package.json | 2 +- src/repository/baserepository.ts | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 893e3ad..d27e468 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tfso/njs-repository", - "version": "1.2.158", + "version": "1.2.159", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 74ae92b..f62fda8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tfso/njs-repository", - "version": "1.2.158", + "version": "1.2.159", "description": "CRUD repository using JavaScript Expressions as a boolean predicate for database queries ", "author": { "name": "Lostfields" diff --git a/src/repository/baserepository.ts b/src/repository/baserepository.ts index 539e662..555146d 100644 --- a/src/repository/baserepository.ts +++ b/src/repository/baserepository.ts @@ -61,7 +61,10 @@ abstract class BaseRepository implements IBaseRepository): boolean { + protected isQueryPageable(query?: IEnumerable): boolean { + if(query == null) + return true + let where = query.operations.first(OperatorType.Where); if (where) @@ -70,7 +73,7 @@ abstract class BaseRepository implements IBaseRepository): Array { + protected getCriteriaGroups(query?: IEnumerable): Array { if(query instanceof Enumerable) { for (let operator of query.operations.values()) @@ -87,8 +90,8 @@ abstract class BaseRepository implements IBaseRepository): FilterCriteria[] - protected getCriteria(expressions: ILogicalExpression[]): FilterCriteria[] + protected getCriteria(query?: IEnumerable): FilterCriteria[] + protected getCriteria(expressions?: ILogicalExpression[]): FilterCriteria[] protected getCriteria() { if(arguments[0] instanceof Enumerable) { @@ -137,4 +140,3 @@ abstract class BaseRepository implements IBaseRepository