fix(mongodb): avoid exact count for unfiltered queries
This commit is contained in:
1 parent
7e0f77eded
commit
3da4dd5ff9
18 files changed
+304
-36
No files matched your search
@@ -0,0 +1,20 @@
|
||||
export interface DocumentQueryTotals {
|
||||
total: number;
|
||||
totalIsExact: boolean;
|
||||
paginationTotal: number | undefined;
|
||||
}
|
||||
|
||||
export function resolveDocumentQueryTotals(total: number, totalIsExact: boolean): DocumentQueryTotals {
|
||||
return {
|
||||
total,
|
||||
totalIsExact,
|
||||
paginationTotal: totalIsExact ? total : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function canGoNextDocumentPage(options: { page: number; pageSize: number; rowCount: number; paginationTotal?: number }): boolean {
|
||||
if (typeof options.paginationTotal === "number") {
|
||||
return (options.page + 1) * options.pageSize < options.paginationTotal;
|
||||
}
|
||||
return options.rowCount >= options.pageSize;
|
||||
}
|
||||
Reference in new issue
Block a user