Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 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": "@labkey/api",
"version": "1.52.4",
"version": "1.52.5-fb-limitMaxCount.1",
"description": "JavaScript client API for LabKey Server",
"scripts": {
"build": "npm run build:dist && npm run build:docs",
Expand Down
8 changes: 8 additions & 0 deletions src/labkey/query/ExecuteSql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export interface ExecuteSqlOptions extends RequestCallbackOptions {
* If false totalCount will equal number of rows returned (equal to maxRows unless maxRows == 0).
*/
includeTotalCount?: boolean;
/**
* Cap the total-count query at this many rows so COUNT(*) is performant. When exceeded the response reports
* rowCount clamped to this value and rowCountCapped: true. Omitted or 0 counts exactly (the default).
*/
maxCount?: number;
/** The maximum number of rows to return from the server (defaults to returning 100,000 rows). */
maxRows?: number;
/**
Expand Down Expand Up @@ -117,6 +122,9 @@ function buildParams(options: ExecuteSqlOptions): any {
if (options.includeTotalCount !== undefined) {
jsonData.includeTotalCount = options.includeTotalCount;
}
if (options.maxCount !== undefined) {
jsonData.maxCount = options.maxCount;
}

if (options.containerFilter) {
jsonData.containerFilter = options.containerFilter;
Expand Down
2 changes: 2 additions & 0 deletions src/labkey/query/Response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ export class Response {
metaData: ResponseMetadata;
queryName: string;
rowCount: number;
/** True when rowCount was capped at the request's maxCount rather than counted exactly. Absent unless maxCount was hit. */
rowCountCapped?: boolean;
rows: Row[];
schemaKey: SchemaKey;
schemaName: string;
Expand Down
8 changes: 8 additions & 0 deletions src/labkey/query/SelectRows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export interface SelectRowsOptions extends RequestCallbackOptions {
* number of rows returned (equal to maxRows unless maxRows == 0).
*/
includeTotalCount?: boolean;
/**
* Cap the total-count query at this many rows, so a large grid's COUNT(*) won't do a full scan.
* When exceeded the response reports rowCount clamped to this value and rowCountCapped: true. Omitted or 0
* counts exactly (the default). Only affects the count; row data is unaffected.
*/
maxCount?: number;
/**
* Include the Update (or edit) link column in the set of columns (defaults to false). If included, the column
* will have the name "~~Update~~". The underlying table/query must support update links or the column
Expand Down Expand Up @@ -172,6 +178,8 @@ function buildSelectRowsParams(options: SelectRowsOptions): any {

if (options.includeTotalCount !== undefined) params.includeTotalCount = options.includeTotalCount;

if (options.maxCount !== undefined) params.maxCount = options.maxCount;

if (options.includeDetailsColumn) params.includeDetailsColumn = options.includeDetailsColumn;

if (options.includeUpdateColumn) params.includeUpdateColumn = options.includeUpdateColumn;
Expand Down