Skip to content

Commit cdc1920

Browse files
authored
feat(QueryService): Handle batching for queries that do not return total matched (#76)
* feat(QueryService): Handle batching for queries that do not return total matched * feat(QueryService): refactor
1 parent 3467477 commit cdc1920

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/services/QueryService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class QueryService<T> {
1111
http: AxiosInstance;
1212
meta: MetaService;
1313
records = [];
14-
parameters: { fields; orderBy?: string[]; start: number; count: number; where?: string; layout?: string; sort?; query?} = {
14+
parameters: { fields; orderBy?: string[]; start: number; count: number; where?: string; layout?: string; sort?; query?; showTotalMatched?: boolean} = {
1515
fields: ['id'],
1616
orderBy: ['-dateAdded'],
1717
start: 0,
@@ -127,6 +127,9 @@ export class QueryService<T> {
127127

128128
private shouldPullMoreRecords({ count = 0, start = 0, total = 0 }) {
129129
const [nextStart, nextCount] = this.getNext(start, count);
130+
if (!this.parameters.showTotalMatched) {
131+
return (count === 0) ? false : (nextCount > 0);
132+
}
130133
return (nextStart < total && count !== 0) ? nextCount : 0;
131134
}
132135

0 commit comments

Comments
 (0)