fix: do not override where clause (#69)
This commit is contained in:
parent
750d7850b9
commit
75cf154585
@ -115,11 +115,8 @@ export async function paginate<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasWhereClause = false
|
|
||||||
|
|
||||||
if (config.where) {
|
if (config.where) {
|
||||||
queryBuilder = queryBuilder.where(config.where)
|
queryBuilder = queryBuilder.andWhere(config.where)
|
||||||
hasWhereClause = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.search && config.searchableColumns) {
|
if (query.search && config.searchableColumns) {
|
||||||
@ -127,8 +124,7 @@ export async function paginate<T>(
|
|||||||
for (const column of config.searchableColumns) {
|
for (const column of config.searchableColumns) {
|
||||||
search.push({ [column]: ILike(`%${query.search}%`) })
|
search.push({ [column]: ILike(`%${query.search}%`) })
|
||||||
}
|
}
|
||||||
queryBuilder = queryBuilder[hasWhereClause ? 'andWhere' : 'where'](search)
|
queryBuilder = queryBuilder.andWhere(search)
|
||||||
hasWhereClause = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.filter) {
|
if (query.filter) {
|
||||||
@ -196,7 +192,7 @@ export async function paginate<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queryBuilder = queryBuilder[hasWhereClause ? 'andWhere' : 'where'](filter)
|
queryBuilder = queryBuilder.andWhere(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
;[items, totalItems] = await queryBuilder.getManyAndCount()
|
;[items, totalItems] = await queryBuilder.getManyAndCount()
|
||||||
|
Loading…
Reference in New Issue
Block a user