dbgate-datalib 5.1.2 → 5.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,7 @@ export declare class PerspectiveCacheTable {
20
20
  bindingGroups: {
21
21
  [bindingKey: string]: PerspectiveBindingGroup;
22
22
  };
23
+ allRowCount: number;
23
24
  get loadedCount(): number;
24
25
  getRowsResult(props: PerspectiveDataLoadProps): {
25
26
  rows: any[];
@@ -25,6 +25,7 @@ class PerspectiveCacheTable {
25
25
  this.cache = cache;
26
26
  this.loadedRows = [];
27
27
  this.bindingGroups = {};
28
+ this.allRowCount = null;
28
29
  this.schemaName = props.schemaName;
29
30
  this.pureName = props.pureName;
30
31
  this.bindingColumns = props.bindingColumns;
@@ -6,4 +6,5 @@ export declare class PerspectiveDataLoader {
6
6
  buildCondition(props: PerspectiveDataLoadProps): Condition;
7
7
  loadGrouping(props: PerspectiveDataLoadProps): Promise<any>;
8
8
  loadData(props: PerspectiveDataLoadProps): Promise<any>;
9
+ loadRowCount(props: PerspectiveDataLoadProps): Promise<any>;
9
10
  }
@@ -135,5 +135,32 @@ class PerspectiveDataLoader {
135
135
  return response.rows;
136
136
  });
137
137
  }
138
+ loadRowCount(props) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const { schemaName, pureName, bindingColumns, bindingValues, dataColumns, orderBy, condition } = props;
141
+ const select = {
142
+ commandType: 'select',
143
+ from: {
144
+ name: { schemaName, pureName },
145
+ },
146
+ columns: [
147
+ {
148
+ exprType: 'raw',
149
+ sql: 'COUNT(*)',
150
+ alias: 'count',
151
+ },
152
+ ],
153
+ where: this.buildCondition(props),
154
+ };
155
+ const response = yield this.apiCall('database-connections/sql-select', {
156
+ conid: props.databaseConfig.conid,
157
+ database: props.databaseConfig.database,
158
+ select,
159
+ });
160
+ if (response.errorMessage)
161
+ return response;
162
+ return response.rows[0];
163
+ });
164
+ }
138
165
  }
139
166
  exports.PerspectiveDataLoader = PerspectiveDataLoader;
@@ -39,4 +39,5 @@ export declare class PerspectiveDataProvider {
39
39
  rows: any[];
40
40
  incomplete: boolean;
41
41
  }>;
42
+ loadRowCount(props: PerspectiveDataLoadProps): Promise<number>;
42
43
  }
@@ -177,5 +177,19 @@ class PerspectiveDataProvider {
177
177
  return tableCache.getRowsResult(props);
178
178
  });
179
179
  }
180
+ loadRowCount(props) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ const tableCache = this.cache.getTableCache(props);
183
+ if (tableCache.allRowCount != null) {
184
+ return tableCache.allRowCount;
185
+ }
186
+ const result = yield this.loader.loadRowCount(Object.assign({}, props));
187
+ if (result.errorMessage) {
188
+ throw new Error(result.errorMessage);
189
+ }
190
+ tableCache.allRowCount = parseInt(result.count);
191
+ return tableCache.allRowCount;
192
+ });
193
+ }
180
194
  }
181
195
  exports.PerspectiveDataProvider = PerspectiveDataProvider;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.1.2",
2
+ "version": "5.1.4",
3
3
  "name": "dbgate-datalib",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -13,12 +13,12 @@
13
13
  "lib"
14
14
  ],
15
15
  "dependencies": {
16
- "dbgate-sqltree": "^5.1.2",
17
- "dbgate-tools": "^5.1.2",
18
- "dbgate-filterparser": "^5.1.2"
16
+ "dbgate-sqltree": "^5.1.4",
17
+ "dbgate-tools": "^5.1.4",
18
+ "dbgate-filterparser": "^5.1.4"
19
19
  },
20
20
  "devDependencies": {
21
- "dbgate-types": "^5.1.2",
21
+ "dbgate-types": "^5.1.4",
22
22
  "@types/node": "^13.7.0",
23
23
  "jest": "^28.1.3",
24
24
  "ts-jest": "^28.0.7",