Skip to content

Commit a4d08c9

Browse files
authored
feat(@cubejs-client/core): expose total rows (#7140) (#7372) Thanks @hannosgit!
1 parent b1da6c0 commit a4d08c9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/cubejs-client-core/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,11 @@ declare module '@cubejs-client/core' {
731731
query(): Query;
732732
rawData(): T[];
733733
annotation(): QueryAnnotations;
734+
735+
/**
736+
* @return the total number of rows if the `total` option was set, when sending the query
737+
*/
738+
totalRows(): number | null;
734739
}
735740

736741
export type Filter = BinaryFilter | UnaryFilter | LogicalOrFilter | LogicalAndFilter;

packages/cubejs-client-core/src/ResultSet.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ class ResultSet {
701701
return this.loadResponse.pivotQuery || null;
702702
}
703703

704+
totalRows() {
705+
return this.loadResponses[0].total;
706+
}
707+
704708
rawData() {
705709
if (this.queryType !== QUERY_TYPE.REGULAR_QUERY) {
706710
throw new Error(`Method is not supported for a '${this.queryType}' query type. Please use decompose`);

0 commit comments

Comments
 (0)