Skip to content

Commit

Permalink
chore: make query optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lostfields committed Jun 12, 2024
1 parent 068e78c commit d8f2969
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
12 changes: 7 additions & 5 deletions src/repository/baserepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ abstract class BaseRepository<TEntity, TEntityId> implements IBaseRepository<TEn
return Promise.resolve();
}

protected isQueryPageable(query: IEnumerable<TEntity>): boolean {
protected isQueryPageable(query?: IEnumerable<TEntity>): boolean {
if(query == null)
return true

let where = query.operations.first(OperatorType.Where);

if (where)
Expand All @@ -70,7 +73,7 @@ abstract class BaseRepository<TEntity, TEntityId> implements IBaseRepository<TEn
return true;
}

protected getCriteriaGroups(query: IEnumerable<TEntity>): Array<FilterCriteria[]> {
protected getCriteriaGroups(query?: IEnumerable<TEntity>): Array<FilterCriteria[]> {
if(query instanceof Enumerable)
{
for (let operator of query.operations.values())
Expand All @@ -87,8 +90,8 @@ abstract class BaseRepository<TEntity, TEntityId> implements IBaseRepository<TEn
return [];
}

protected getCriteria(query: IEnumerable<TEntity>): FilterCriteria[]
protected getCriteria(expressions: ILogicalExpression[]): FilterCriteria[]
protected getCriteria(query?: IEnumerable<TEntity>): FilterCriteria[]
protected getCriteria(expressions?: ILogicalExpression[]): FilterCriteria[]
protected getCriteria() {
if(arguments[0] instanceof Enumerable)
{
Expand Down Expand Up @@ -137,4 +140,3 @@ abstract class BaseRepository<TEntity, TEntityId> implements IBaseRepository<TEn
}

export default BaseRepository

0 comments on commit d8f2969

Please sign in to comment.