Skip to content

Commit

Permalink
feat(@cubejs-client/core): expose total rows (#7140) (#7372) Thanks @…
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosgit committed Nov 11, 2023
1 parent b1da6c0 commit a4d08c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cubejs-client-core/index.d.ts
Expand Up @@ -731,6 +731,11 @@ declare module '@cubejs-client/core' {
query(): Query;
rawData(): T[];
annotation(): QueryAnnotations;

/**
* @return the total number of rows if the `total` option was set, when sending the query
*/
totalRows(): number | null;
}

export type Filter = BinaryFilter | UnaryFilter | LogicalOrFilter | LogicalAndFilter;
Expand Down
4 changes: 4 additions & 0 deletions packages/cubejs-client-core/src/ResultSet.js
Expand Up @@ -701,6 +701,10 @@ class ResultSet {
return this.loadResponse.pivotQuery || null;
}

totalRows() {
return this.loadResponses[0].total;
}

rawData() {
if (this.queryType !== QUERY_TYPE.REGULAR_QUERY) {
throw new Error(`Method is not supported for a '${this.queryType}' query type. Please use decompose`);
Expand Down

0 comments on commit a4d08c9

Please sign in to comment.