Skip to content

Commit cac0550

Browse files
committed
fix: update query builder
1 parent 9bb23d1 commit cac0550

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/lib/query-builder/filtered.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { ObjectLiteral } from 'typeorm'
22
import { validate } from '../validate'
33
import { ApplyFilterParams, QueryFilters } from './types'
44

5+
/**
6+
* Apply filter
7+
*/
58
export function applyFilter<T extends ObjectLiteral>({
69
query,
710
filters,

src/lib/query-builder/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { applyPagination } from './pagination'
66
import { applySort } from './sorted'
77
import { QueryBuilderParams } from './types'
88

9+
/**
10+
* Query builder for TypeORM
11+
*/
912
export function QueryBuilder<T extends ObjectLiteral>({ params, options }: QueryBuilderParams<T>) {
1013
const { query, model, reqQuery, options: opt } = params
1114

src/lib/query-builder/pagination.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { ObjectLiteral } from 'typeorm'
22
import { validate } from '../validate'
33
import { ApplyPaginationParams, CalculatePageSizeParams } from './types'
44

5+
/**
6+
* Calculate page size
7+
*/
58
function _calculatePageSize({ pageSize, limit }: CalculatePageSizeParams) {
69
const min = 10
710
const parsePageSize = validate.number(pageSize)
@@ -13,6 +16,9 @@ function _calculatePageSize({ pageSize, limit }: CalculatePageSizeParams) {
1316
return min
1417
}
1518

19+
/**
20+
* Apply pagination to query
21+
*/
1622
export function applyPagination<T extends ObjectLiteral>({
1723
query,
1824
page,

src/lib/query-builder/sorted.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { ObjectLiteral } from 'typeorm'
22
import { ApplySortParams, QuerySorts } from './types'
33

4+
/**
5+
* Apply sort to query
6+
*/
47
export function applySort<T extends ObjectLiteral>({
58
query,
69
sorts,

0 commit comments

Comments
 (0)