@itwin/core-backend 3.0.0-dev.98 → 3.0.0
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.
- package/CHANGELOG.md +211 -67
- package/LICENSE.md +1 -1
- package/lib/cjs/AliCloudStorageService.d.ts +8 -2
- package/lib/cjs/AliCloudStorageService.d.ts.map +1 -1
- package/lib/cjs/AliCloudStorageService.js +4 -5
- package/lib/cjs/AliCloudStorageService.js.map +1 -1
- package/lib/cjs/BackendHubAccess.d.ts +9 -9
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js +4 -3
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +1 -1
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +6 -6
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -0
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +2 -0
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +10 -7
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +10 -3
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.d.ts +2 -3
- package/lib/cjs/CloudStorageBackend.d.ts.map +1 -1
- package/lib/cjs/CloudStorageBackend.js +5 -2
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +7 -0
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/DevTools.d.ts +2 -2
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +2 -2
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +15 -47
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +5 -9
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +11 -14
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.d.ts +1 -0
- package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +10 -4
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +8 -8
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +24 -15
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +16 -16
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +9 -9
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +2 -2
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +2 -2
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/Entity.d.ts +11 -3
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +10 -2
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/ExportGraphics.d.ts +1 -1
- package/lib/cjs/ExportGraphics.d.ts.map +1 -1
- package/lib/cjs/ExportGraphics.js +3 -0
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +5 -2
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +44 -26
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +114 -42
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +40 -19
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +70 -20
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js +2 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +10 -3
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.d.ts +1 -1
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +4 -4
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +3 -3
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts +4 -22
- package/lib/cjs/NativeHost.d.ts.map +1 -1
- package/lib/cjs/NativeHost.js +4 -56
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +10 -9
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +14 -8
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts +4 -0
- package/lib/cjs/RpcBackend.d.ts.map +1 -1
- package/lib/cjs/RpcBackend.js +7 -0
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.d.ts +4 -10
- package/lib/cjs/ServerBasedLocks.d.ts.map +1 -1
- package/lib/cjs/ServerBasedLocks.js +12 -20
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.js +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TxnManager.js +1 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +11 -11
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +5 -5
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/assets/Settings.schema.json +25 -0
- package/lib/cjs/core-backend.d.ts +8 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +9 -1
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +2 -2
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +33 -24
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +10 -7
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +11 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js +3 -0
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +182 -0
- package/lib/cjs/workspace/Settings.d.ts.map +1 -0
- package/lib/cjs/workspace/Settings.js +144 -0
- package/lib/cjs/workspace/Settings.js.map +1 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.d.ts +68 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.d.ts.map +1 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.js +122 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.js.map +1 -0
- package/lib/cjs/workspace/Workspace.d.ts +306 -0
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -0
- package/lib/cjs/workspace/Workspace.js +372 -0
- package/lib/cjs/workspace/Workspace.js.map +1 -0
- package/package.json +33 -19
package/lib/cjs/ECDb.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
2
1
|
/** @packageDocumentation
|
|
3
2
|
* @module ECDb
|
|
4
3
|
*/
|
|
5
4
|
import { IDisposable } from "@itwin/core-bentley";
|
|
6
|
-
import {
|
|
5
|
+
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
6
|
+
import { ECSqlReader, QueryBinder, QueryOptions } from "@itwin/core-common";
|
|
7
7
|
import { ECSqlStatement } from "./ECSqlStatement";
|
|
8
8
|
import { SqliteStatement } from "./SqliteStatement";
|
|
9
9
|
/** Modes for how to open [ECDb]($backend) files.
|
|
@@ -20,10 +20,8 @@ export declare enum ECDbOpenMode {
|
|
|
20
20
|
*/
|
|
21
21
|
export declare class ECDb implements IDisposable {
|
|
22
22
|
private _nativeDb?;
|
|
23
|
-
private _concurrentQueryInitialized;
|
|
24
23
|
private readonly _statementCache;
|
|
25
24
|
private _sqliteStatementCache;
|
|
26
|
-
private _concurrentQueryStats;
|
|
27
25
|
/** only for tests
|
|
28
26
|
* @internal
|
|
29
27
|
*/
|
|
@@ -153,13 +151,12 @@ export declare class ECDb implements IDisposable {
|
|
|
153
151
|
*
|
|
154
152
|
* @param ecsql The ECSQL statement to execute
|
|
155
153
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
156
|
-
* @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*
|
|
157
154
|
* @param options Allow to specify certain flags which control how query is executed.
|
|
158
155
|
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
159
156
|
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
160
157
|
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
161
158
|
*/
|
|
162
|
-
query(ecsql: string, params?: QueryBinder,
|
|
159
|
+
query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any>;
|
|
163
160
|
/** Compute number of rows that would be returned by the ECSQL.
|
|
164
161
|
*
|
|
165
162
|
* See also:
|
|
@@ -168,7 +165,7 @@ export declare class ECDb implements IDisposable {
|
|
|
168
165
|
*
|
|
169
166
|
* @param ecsql The ECSQL statement to execute
|
|
170
167
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
171
|
-
* See "[
|
|
168
|
+
* See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
|
|
172
169
|
* @returns Return row count.
|
|
173
170
|
* @throws [IModelError]($common) If the statement is invalid
|
|
174
171
|
*/
|
|
@@ -185,12 +182,11 @@ export declare class ECDb implements IDisposable {
|
|
|
185
182
|
* @param token None empty restart token. The previous query with same token would be cancelled. This would cause
|
|
186
183
|
* exception which user code must handle.
|
|
187
184
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
188
|
-
* @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*
|
|
189
185
|
* @param options Allow to specify certain flags which control how query is executed.
|
|
190
186
|
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
191
187
|
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
192
188
|
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
193
189
|
*/
|
|
194
|
-
restartQuery(token: string, ecsql: string, params?: QueryBinder,
|
|
190
|
+
restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any>;
|
|
195
191
|
}
|
|
196
192
|
//# sourceMappingURL=ECDb.d.ts.map
|
package/lib/cjs/ECDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAoB,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAkB,WAAW,EAAe,WAAW,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AAG9H,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AAIpE;;GAEG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAA;IACR,SAAS,IAAA;IACT,sGAAsG;IACtG,WAAW,IAAA;CACZ;AAED;;GAEG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC,OAAO,CAAC,SAAS,CAAC,CAAsB;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwC;IACxE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AM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,CAAC,EAAE,SAAS,UAAO,GAAG,CAAC;IAiBvG;;;;;OAKG;IACI,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,eAAe;IAM7E,gBAAgB;IAChB,IAAW,QAAQ,IAAI,cAAc,CAAC,IAAI,CAGzC;IAED;;;;;SAKK;IACE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW;IAYjG;;;;;;;;;;;;;;OAcG;IACY,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC,GAAG,CAAC;IAM7G;;;;;;;;;;;OAWG;IACU,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAOhF;;;;;;;;;;;;;;;;OAgBG;IACY,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC,GAAG,CAAC;CAKpI"}
|
package/lib/cjs/ECDb.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ECDb = exports.ECDbOpenMode = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
4
8
|
/** @packageDocumentation
|
|
5
9
|
* @module ECDb
|
|
6
10
|
*/
|
|
@@ -27,10 +31,8 @@ var ECDbOpenMode;
|
|
|
27
31
|
*/
|
|
28
32
|
class ECDb {
|
|
29
33
|
constructor() {
|
|
30
|
-
this._concurrentQueryInitialized = false;
|
|
31
34
|
this._statementCache = new SqliteStatement_1.StatementCache();
|
|
32
35
|
this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
33
|
-
this._concurrentQueryStats = { resetTimerHandle: null, logTimerHandle: null, lastActivityTime: Date.now(), dispose: () => { } };
|
|
34
36
|
this._nativeDb = new IModelHost_1.IModelHost.platform.ECDb();
|
|
35
37
|
}
|
|
36
38
|
/** only for tests
|
|
@@ -80,7 +82,6 @@ class ECDb {
|
|
|
80
82
|
this._statementCache.clear();
|
|
81
83
|
this._sqliteStatementCache.clear();
|
|
82
84
|
this.nativeDb.closeDb();
|
|
83
|
-
this._concurrentQueryStats.dispose();
|
|
84
85
|
}
|
|
85
86
|
/** @internal use to test statement caching */
|
|
86
87
|
clearStatementCache() {
|
|
@@ -264,6 +265,7 @@ class ECDb {
|
|
|
264
265
|
}
|
|
265
266
|
/** @internal */
|
|
266
267
|
get nativeDb() {
|
|
268
|
+
(0, core_bentley_1.assert)(undefined !== this._nativeDb);
|
|
267
269
|
return this._nativeDb;
|
|
268
270
|
}
|
|
269
271
|
/** Allow to execute query and read results along with meta data. The result are streamed.
|
|
@@ -278,7 +280,7 @@ class ECDb {
|
|
|
278
280
|
}
|
|
279
281
|
const executor = {
|
|
280
282
|
execute: async (request) => {
|
|
281
|
-
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.
|
|
283
|
+
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.nativeDb, request);
|
|
282
284
|
},
|
|
283
285
|
};
|
|
284
286
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
|
@@ -293,20 +295,16 @@ class ECDb {
|
|
|
293
295
|
*
|
|
294
296
|
* @param ecsql The ECSQL statement to execute
|
|
295
297
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
296
|
-
* @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*
|
|
297
298
|
* @param options Allow to specify certain flags which control how query is executed.
|
|
298
299
|
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
299
300
|
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
300
301
|
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
301
302
|
*/
|
|
302
|
-
async *query(ecsql, params,
|
|
303
|
+
async *query(ecsql, params, options) {
|
|
303
304
|
const builder = new core_common_1.QueryOptionsBuilder(options);
|
|
304
|
-
if (rowFormat === core_common_1.QueryRowFormat.UseJsPropertyNames) {
|
|
305
|
-
builder.setConvertClassIdsToNames(true);
|
|
306
|
-
}
|
|
307
305
|
const reader = this.createQueryReader(ecsql, params, builder.getOptions());
|
|
308
306
|
while (await reader.step())
|
|
309
|
-
yield reader.formatCurrentRow(
|
|
307
|
+
yield reader.formatCurrentRow();
|
|
310
308
|
}
|
|
311
309
|
/** Compute number of rows that would be returned by the ECSQL.
|
|
312
310
|
*
|
|
@@ -316,7 +314,7 @@ class ECDb {
|
|
|
316
314
|
*
|
|
317
315
|
* @param ecsql The ECSQL statement to execute
|
|
318
316
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
319
|
-
* See "[
|
|
317
|
+
* See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
|
|
320
318
|
* @returns Return row count.
|
|
321
319
|
* @throws [IModelError]($common) If the statement is invalid
|
|
322
320
|
*/
|
|
@@ -338,14 +336,13 @@ class ECDb {
|
|
|
338
336
|
* @param token None empty restart token. The previous query with same token would be cancelled. This would cause
|
|
339
337
|
* exception which user code must handle.
|
|
340
338
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
341
|
-
* @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*
|
|
342
339
|
* @param options Allow to specify certain flags which control how query is executed.
|
|
343
340
|
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
344
341
|
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
345
342
|
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
346
343
|
*/
|
|
347
|
-
async *restartQuery(token, ecsql, params,
|
|
348
|
-
for await (const row of this.query(ecsql, params,
|
|
344
|
+
async *restartQuery(token, ecsql, params, options) {
|
|
345
|
+
for await (const row of this.query(ecsql, params, new core_common_1.QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {
|
|
349
346
|
yield row;
|
|
350
347
|
}
|
|
351
348
|
}
|
package/lib/cjs/ECDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,sDAA8E;AAC9E,oDAA8I;AAC9I,mEAAgE;AAChE,uDAAoD;AACpD,qDAAkD;AAClD,6CAA0C;AAC1C,uDAAoE;AAEpE,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,sGAAsG;IACtG,6DAAW,CAAA;AACb,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAED;;GAEG;AACH,MAAa,IAAI;IAef;QAbQ,gCAA2B,GAAY,KAAK,CAAC;QACpC,oBAAe,GAAG,IAAI,gCAAc,EAAkB,CAAC;QAChE,0BAAqB,GAAG,IAAI,gCAAc,EAAmB,CAAC;QAC9D,0BAAqB,GAAG,EAAE,gBAAgB,EAAG,IAAY,EAAE,cAAc,EAAG,IAAY,EAAE,gBAA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------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { DbQueryRequest, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements IDisposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n private _concurrentQueryInitialized: boolean = false;\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n private _concurrentQueryStats = { resetTimerHandle: (null as any), logTimerHandle: (null as any), lastActivityTime: Date.now(), dispose: () => { } };\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelHost.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this.nativeDb.createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n this._concurrentQueryStats.dispose();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this.nativeDb.saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this.nativeDb.abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this.nativeDb.importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n */\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n */\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this.nativeDb, ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get nativeDb(): IModelJsNative.ECDb {\r\n return this._nativeDb!;\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are streamed.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns *ECSqlQueryReader* which help iterate over result set and also give access to meta data.\r\n * @beta\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this._nativeDb!, request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Execute a query and stream its results\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n */\r\n public async * query(ecsql: string, params?: QueryBinder, rowFormat = QueryRowFormat.UseArrayIndexes, options?: QueryOptions): AsyncIterableIterator<any> {\r\n const builder = new QueryOptionsBuilder(options);\r\n if (rowFormat === QueryRowFormat.UseJsPropertyNames) {\r\n builder.setConvertClassIdsToNames(true);\r\n }\r\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\r\n while (await reader.step())\r\n yield reader.formatCurrentRow(rowFormat);\r\n }\r\n /** Compute number of rows that would be returned by the ECSQL.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * See \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\r\n * @returns Return row count.\r\n * @throws [IModelError]($common) If the statement is invalid\r\n */\r\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\r\n for await (const row of this.query(`select count(*) from (${ecsql})`, params)) {\r\n return row[0] as number;\r\n }\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\r\n }\r\n\r\n /** Cancel any previous query with same token and run execute the current specified query.\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\r\n * exception which user code must handle.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n */\r\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, rowFormat = QueryRowFormat.UseArrayIndexes, options?: QueryOptions): AsyncIterableIterator<any> {\r\n for await (const row of this.query(ecsql, params, rowFormat, new QueryOptionsBuilder(options).setRestartToken(token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AK,CAAC,CAAE,YAAY,CAAC,KAAa,EAAE,KAAa,EAAE,MAAoB,EAAE,OAAsB;QACpG,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,iCAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE;YACvH,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF;AA1UD,oBA0UC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { assert, DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements IDisposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelHost.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this.nativeDb.createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this.nativeDb.saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this.nativeDb.abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this.nativeDb.importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n */\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n */\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this.nativeDb, ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get nativeDb(): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are streamed.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns *ECSqlQueryReader* which help iterate over result set and also give access to meta data.\r\n * @beta\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this.nativeDb, request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Execute a query and stream its results\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n */\r\n public async * query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\r\n const builder = new QueryOptionsBuilder(options);\r\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\r\n while (await reader.step())\r\n yield reader.formatCurrentRow();\r\n }\r\n /** Compute number of rows that would be returned by the ECSQL.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * See \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\r\n * @returns Return row count.\r\n * @throws [IModelError]($common) If the statement is invalid\r\n */\r\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\r\n for await (const row of this.query(`select count(*) from (${ecsql})`, params)) {\r\n return row[0] as number;\r\n }\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\r\n }\r\n\r\n /** Cancel any previous query with same token and run execute the current specified query.\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\r\n * exception which user code must handle.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n */\r\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\r\n for await (const row of this.query(ecsql, params, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\r\n yield row;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -10,6 +10,7 @@ export declare type SchemaMatchType = IModelJsNative.ECSchemaXmlContext.SchemaMa
|
|
|
10
10
|
export declare class ECSchemaXmlContext {
|
|
11
11
|
private _nativeContext;
|
|
12
12
|
constructor();
|
|
13
|
+
get nativeContext(): IModelJsNative.ECSchemaXmlContext;
|
|
13
14
|
addSchemaPath(searchPath: string): void;
|
|
14
15
|
setSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void;
|
|
15
16
|
setFirstSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSchemaXmlContext.d.ts","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ECSchemaXmlContext.d.ts","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,gBAAgB;AAChB,oBAAY,SAAS,GAAG,cAAc,CAAC,kBAAkB,CAAC,SAAS,CAAC;AAEpE,gBAAgB;AAChB,oBAAY,eAAe,GAAG,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC;AAEhF,gBAAgB;AAChB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,cAAc,CAAgD;;IAMtE,IAAW,aAAa,IAAI,cAAc,CAAC,kBAAkB,CAG5D;IAEM,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIvC,gBAAgB,CAAC,OAAO,EAAE,cAAc,CAAC,kBAAkB,CAAC,qBAAqB,GAAG,IAAI;IAIxF,qBAAqB,CAAC,OAAO,EAAE,cAAc,CAAC,kBAAkB,CAAC,qBAAqB,GAAG,IAAI;IAI7F,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG;CASpD"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ECSchemaXmlContext = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
11
12
|
const core_common_1 = require("@itwin/core-common");
|
|
12
13
|
const IModelHost_1 = require("./IModelHost");
|
|
13
14
|
/** @internal */
|
|
@@ -15,20 +16,25 @@ class ECSchemaXmlContext {
|
|
|
15
16
|
constructor() {
|
|
16
17
|
this._nativeContext = new IModelHost_1.IModelHost.platform.ECSchemaXmlContext();
|
|
17
18
|
}
|
|
19
|
+
get nativeContext() {
|
|
20
|
+
(0, core_bentley_1.assert)(undefined !== this._nativeContext);
|
|
21
|
+
return this._nativeContext;
|
|
22
|
+
}
|
|
18
23
|
addSchemaPath(searchPath) {
|
|
19
|
-
this.
|
|
24
|
+
this.nativeContext.addSchemaPath(searchPath);
|
|
20
25
|
}
|
|
21
26
|
setSchemaLocater(locater) {
|
|
22
|
-
this.
|
|
27
|
+
this.nativeContext.setSchemaLocater(locater);
|
|
23
28
|
}
|
|
24
29
|
setFirstSchemaLocater(locater) {
|
|
25
|
-
this.
|
|
30
|
+
this.nativeContext.setFirstSchemaLocater(locater);
|
|
26
31
|
}
|
|
27
32
|
readSchemaFromXmlFile(filePath) {
|
|
28
|
-
const response = this.
|
|
33
|
+
const response = this.nativeContext.readSchemaFromXmlFile(filePath);
|
|
29
34
|
if (response.error) {
|
|
30
35
|
throw new core_common_1.IModelError(response.error.status, response.error.message);
|
|
31
36
|
}
|
|
37
|
+
(0, core_bentley_1.assert)(undefined !== response.result);
|
|
32
38
|
return JSON.parse(response.result);
|
|
33
39
|
}
|
|
34
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSchemaXmlContext.js","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiD;AAEjD,6CAA0C;AAQ1C,gBAAgB;AAChB,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M,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACF;AAjCD,gDAiCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** @internal */\r\nexport type SchemaKey = IModelJsNative.ECSchemaXmlContext.SchemaKey;\r\n\r\n/** @internal */\r\nexport type SchemaMatchType = IModelJsNative.ECSchemaXmlContext.SchemaMatchType;\r\n\r\n/** @internal */\r\nexport class ECSchemaXmlContext {\r\n private _nativeContext: IModelJsNative.ECSchemaXmlContext | undefined;\r\n\r\n constructor() {\r\n this._nativeContext = new IModelHost.platform.ECSchemaXmlContext();\r\n }\r\n\r\n public get nativeContext(): IModelJsNative.ECSchemaXmlContext {\r\n assert(undefined !== this._nativeContext);\r\n return this._nativeContext;\r\n }\r\n\r\n public addSchemaPath(searchPath: string): void {\r\n this.nativeContext.addSchemaPath(searchPath);\r\n }\r\n\r\n public setSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\r\n this.nativeContext.setSchemaLocater(locater);\r\n }\r\n\r\n public setFirstSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\r\n this.nativeContext.setFirstSchemaLocater(locater);\r\n }\r\n\r\n public readSchemaFromXmlFile(filePath: string): any {\r\n const response = this.nativeContext.readSchemaFromXmlFile(filePath);\r\n if (response.error) {\r\n throw new IModelError(response.error.status, response.error.message);\r\n }\r\n\r\n assert(undefined !== response.result);\r\n return JSON.parse(response.result);\r\n }\r\n}\r\n"]}
|
|
@@ -40,8 +40,8 @@ export declare class ECSqlInsertResult {
|
|
|
40
40
|
* > The key to making this strategy work is to phrase a statement in a general way and use placeholders to represent parameters that will vary on each use.
|
|
41
41
|
*
|
|
42
42
|
* See also
|
|
43
|
-
* - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL) provides more background on ECSQL and an introduction on how to execute ECSQL with the
|
|
44
|
-
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the
|
|
43
|
+
* - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL) provides more background on ECSQL and an introduction on how to execute ECSQL with the iTwin.js API.
|
|
44
|
+
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the iTwin.js API for executing and working with ECSQL
|
|
45
45
|
* @public
|
|
46
46
|
*/
|
|
47
47
|
export declare class ECSqlStatement implements IterableIterator<any>, IDisposable {
|
|
@@ -79,8 +79,8 @@ export declare class ECSqlStatement implements IterableIterator<any>, IDisposabl
|
|
|
79
79
|
*/
|
|
80
80
|
dispose(): void;
|
|
81
81
|
/** Binds the specified value to the specified ECSQL parameter.
|
|
82
|
-
* The section "[
|
|
83
|
-
*
|
|
82
|
+
* The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
|
|
83
|
+
* iTwin.js types to be used for the different ECSQL parameter types.
|
|
84
84
|
* @param parameter Index (1-based) or name of the parameter
|
|
85
85
|
*/
|
|
86
86
|
bindValue(parameter: number | string, val: any): void;
|
|
@@ -173,8 +173,8 @@ export declare class ECSqlStatement implements IterableIterator<any>, IDisposabl
|
|
|
173
173
|
* Pass an *object of the values keyed on the parameter name* for *named parameters*.
|
|
174
174
|
* The values in either the array or object must match the respective types of the parameter.
|
|
175
175
|
*
|
|
176
|
-
* The section "[
|
|
177
|
-
*
|
|
176
|
+
* The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
|
|
177
|
+
* iTwin.js types to be used for the different ECSQL parameter types.
|
|
178
178
|
*
|
|
179
179
|
* See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)
|
|
180
180
|
*/
|
|
@@ -250,8 +250,8 @@ export declare class ECSqlBinder {
|
|
|
250
250
|
/** @internal */
|
|
251
251
|
constructor(binder: IModelJsNative.ECSqlBinder);
|
|
252
252
|
/** Binds the specified value to the ECSQL parameter.
|
|
253
|
-
* The section "[
|
|
254
|
-
*
|
|
253
|
+
* The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
|
|
254
|
+
* iTwin.js types to be used for the different ECSQL parameter types.
|
|
255
255
|
* @param val Value to bind
|
|
256
256
|
*/
|
|
257
257
|
bind(val: any): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlStatement.d.ts","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ECSqlStatement.d.ts","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,EAAE,aAAa,EAAW,KAAK,EAAE,MAAM,EAAO,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAa,cAAc,EAAe,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IACF,MAAM,EAAE,QAAQ;IAAS,EAAE,CAAC;gBAA5B,MAAM,EAAE,QAAQ,EAAS,EAAE,CAAC,oBAAY;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,cAA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AGG;IACH,sBAAsB,IAAI,MAAM,CAAC;IAEjC,oGAAoG;IACpG,gBAAgB,IAAI,MAAM,CAAC;IAE3B;;OAEG;IACH,iBAAiB,IAAI,MAAM,CAAC;CAC7B"}
|
|
@@ -49,12 +49,12 @@ exports.ECSqlInsertResult = ECSqlInsertResult;
|
|
|
49
49
|
* > The key to making this strategy work is to phrase a statement in a general way and use placeholders to represent parameters that will vary on each use.
|
|
50
50
|
*
|
|
51
51
|
* See also
|
|
52
|
-
* - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL) provides more background on ECSQL and an introduction on how to execute ECSQL with the
|
|
53
|
-
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the
|
|
52
|
+
* - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL) provides more background on ECSQL and an introduction on how to execute ECSQL with the iTwin.js API.
|
|
53
|
+
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the iTwin.js API for executing and working with ECSQL
|
|
54
54
|
* @public
|
|
55
55
|
*/
|
|
56
56
|
class ECSqlStatement {
|
|
57
|
-
get sql() { return this._sql; }
|
|
57
|
+
get sql() { return this._sql; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
58
58
|
/** Check if this statement has been prepared successfully or not */
|
|
59
59
|
get isPrepared() { return !!this._stmt; }
|
|
60
60
|
/** Prepare this statement prior to first use.
|
|
@@ -87,12 +87,14 @@ class ECSqlStatement {
|
|
|
87
87
|
}
|
|
88
88
|
/** Reset this statement so that the next call to step will return the first row, if any. */
|
|
89
89
|
reset() {
|
|
90
|
+
(0, core_bentley_1.assert)(undefined !== this._stmt);
|
|
90
91
|
this._stmt.reset();
|
|
91
92
|
}
|
|
92
93
|
/** Get the Native SQL statement
|
|
93
94
|
* @internal
|
|
94
95
|
*/
|
|
95
96
|
getNativeSql() {
|
|
97
|
+
(0, core_bentley_1.assert)(undefined !== this._stmt);
|
|
96
98
|
return this._stmt.getNativeSql();
|
|
97
99
|
}
|
|
98
100
|
/** Call this function when finished with this statement. This releases the native resources held by the statement.
|
|
@@ -106,8 +108,8 @@ class ECSqlStatement {
|
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
/** Binds the specified value to the specified ECSQL parameter.
|
|
109
|
-
* The section "[
|
|
110
|
-
*
|
|
111
|
+
* The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
|
|
112
|
+
* iTwin.js types to be used for the different ECSQL parameter types.
|
|
111
113
|
* @param parameter Index (1-based) or name of the parameter
|
|
112
114
|
*/
|
|
113
115
|
bindValue(parameter, val) { this.getBinder(parameter).bind(val); }
|
|
@@ -193,15 +195,18 @@ class ECSqlStatement {
|
|
|
193
195
|
* > or [ECSqlStatement.bindValues]($backend).
|
|
194
196
|
* @param parameter Index (1-based) or name of the parameter
|
|
195
197
|
*/
|
|
196
|
-
getBinder(parameter) {
|
|
198
|
+
getBinder(parameter) {
|
|
199
|
+
(0, core_bentley_1.assert)(undefined !== this._stmt);
|
|
200
|
+
return new ECSqlBinder(this._stmt.getBinder(parameter));
|
|
201
|
+
}
|
|
197
202
|
/** Bind values to all parameters in the statement.
|
|
198
203
|
* @param values The values to bind to the parameters.
|
|
199
204
|
* Pass an *array* of values if the parameters are *positional*.
|
|
200
205
|
* Pass an *object of the values keyed on the parameter name* for *named parameters*.
|
|
201
206
|
* The values in either the array or object must match the respective types of the parameter.
|
|
202
207
|
*
|
|
203
|
-
* The section "[
|
|
204
|
-
*
|
|
208
|
+
* The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
|
|
209
|
+
* iTwin.js types to be used for the different ECSQL parameter types.
|
|
205
210
|
*
|
|
206
211
|
* See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)
|
|
207
212
|
*/
|
|
@@ -249,11 +254,11 @@ class ECSqlStatement {
|
|
|
249
254
|
*
|
|
250
255
|
* See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples)
|
|
251
256
|
*/
|
|
252
|
-
step() { return this._stmt.step(); }
|
|
257
|
+
step() { return this._stmt.step(); } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
253
258
|
/** @internal added this back in for testing purposes */
|
|
254
259
|
async stepAsync() {
|
|
255
260
|
return new Promise((resolve, _reject) => {
|
|
256
|
-
this._stmt.stepAsync(resolve);
|
|
261
|
+
this._stmt.stepAsync(resolve); // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
257
262
|
});
|
|
258
263
|
}
|
|
259
264
|
/** Step this INSERT statement and returns status and the ECInstanceId of the newly
|
|
@@ -265,13 +270,14 @@ class ECSqlStatement {
|
|
|
265
270
|
* call. In case of error, the respective error code is returned.
|
|
266
271
|
*/
|
|
267
272
|
stepForInsert() {
|
|
273
|
+
(0, core_bentley_1.assert)(undefined !== this._stmt);
|
|
268
274
|
const r = this._stmt.stepForInsert();
|
|
269
275
|
if (r.status === core_bentley_1.DbResult.BE_SQLITE_DONE)
|
|
270
276
|
return new ECSqlInsertResult(r.status, r.id);
|
|
271
277
|
return new ECSqlInsertResult(r.status);
|
|
272
278
|
}
|
|
273
279
|
/** Get the query result's column count (only for ECSQL SELECT statements). */
|
|
274
|
-
getColumnCount() { return this._stmt.getColumnCount(); }
|
|
280
|
+
getColumnCount() { return this._stmt.getColumnCount(); } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
275
281
|
/** Get the current row.
|
|
276
282
|
* The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.
|
|
277
283
|
*
|
|
@@ -333,7 +339,10 @@ class ECSqlStatement {
|
|
|
333
339
|
*
|
|
334
340
|
* See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)
|
|
335
341
|
*/
|
|
336
|
-
getValue(columnIx) {
|
|
342
|
+
getValue(columnIx) {
|
|
343
|
+
(0, core_bentley_1.assert)(undefined !== this._stmt);
|
|
344
|
+
return new ECSqlValue(this._stmt.getValue(columnIx));
|
|
345
|
+
}
|
|
337
346
|
}
|
|
338
347
|
exports.ECSqlStatement = ECSqlStatement;
|
|
339
348
|
/** Binds a value to an ECSQL parameter.
|
|
@@ -349,8 +358,8 @@ class ECSqlBinder {
|
|
|
349
358
|
/** @internal */
|
|
350
359
|
constructor(binder) { this._binder = binder; }
|
|
351
360
|
/** Binds the specified value to the ECSQL parameter.
|
|
352
|
-
* The section "[
|
|
353
|
-
*
|
|
361
|
+
* The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
|
|
362
|
+
* iTwin.js types to be used for the different ECSQL parameter types.
|
|
354
363
|
* @param val Value to bind
|
|
355
364
|
*/
|
|
356
365
|
bind(val) {
|
|
@@ -576,7 +585,7 @@ exports.ECSqlValueIterator = ECSqlValueIterator;
|
|
|
576
585
|
class ECSqlBindingHelper {
|
|
577
586
|
/** Binds the specified value to the specified binder
|
|
578
587
|
* @param binder Parameter Binder to bind to
|
|
579
|
-
* @param val Value to be bound. (See [
|
|
588
|
+
* @param val Value to be bound. (See [iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes))
|
|
580
589
|
* @throws IModelError in case of errors
|
|
581
590
|
*/
|
|
582
591
|
static bindValue(binder, val) {
|