@itwin/core-backend 5.12.0-dev.2 → 5.12.0-dev.6
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 +15 -1
- package/lib/cjs/BackendHubAccess.d.ts +1 -1
- package/lib/cjs/BackendHubAccess.js +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +33 -37
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +4 -7
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts +1 -1
- package/lib/cjs/ClassRegistry.js +1 -1
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +4 -4
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +4 -4
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +6 -6
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +4 -4
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +1 -1
- package/lib/cjs/Element.js +1 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +1 -1
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +7 -11
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +16 -24
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.d.ts +1 -1
- package/lib/cjs/Entity.js +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +14 -14
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +77 -97
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +2 -2
- package/lib/cjs/IModelHost.js +2 -2
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +8 -11
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +1 -1
- package/lib/cjs/SQLiteDb.js +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +1 -1
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +8 -12
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +6 -8
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +8 -11
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +6 -10
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
- package/lib/cjs/internal/annotations/fields.js +19 -43
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +8 -7
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +2 -3
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +28 -2
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/esm/BackendHubAccess.d.ts +1 -1
- package/lib/esm/BackendHubAccess.js +1 -1
- package/lib/esm/BackendHubAccess.js.map +1 -1
- package/lib/esm/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/esm/ChangeSummaryManager.js +34 -38
- package/lib/esm/ChangeSummaryManager.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +5 -8
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ClassRegistry.d.ts +1 -1
- package/lib/esm/ClassRegistry.js +1 -1
- package/lib/esm/ClassRegistry.js.map +1 -1
- package/lib/esm/ECDb.d.ts +4 -4
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +4 -4
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +6 -6
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js +4 -4
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.d.ts +1 -1
- package/lib/esm/Element.js +1 -1
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts +1 -1
- package/lib/esm/ElementAspect.d.ts.map +1 -1
- package/lib/esm/ElementAspect.js +9 -13
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementTreeWalker.d.ts.map +1 -1
- package/lib/esm/ElementTreeWalker.js +18 -26
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/Entity.d.ts +1 -1
- package/lib/esm/Entity.js +1 -1
- package/lib/esm/Entity.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +14 -14
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +78 -98
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelElementCloneContext.d.ts +1 -1
- package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/esm/IModelElementCloneContext.js +1 -1
- package/lib/esm/IModelElementCloneContext.js.map +1 -1
- package/lib/esm/IModelHost.d.ts +2 -2
- package/lib/esm/IModelHost.js +2 -2
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +9 -12
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/SQLiteDb.d.ts +1 -1
- package/lib/esm/SQLiteDb.js +1 -1
- package/lib/esm/SQLiteDb.js.map +1 -1
- package/lib/esm/SqliteStatement.d.ts +1 -1
- package/lib/esm/SqliteStatement.d.ts.map +1 -1
- package/lib/esm/SqliteStatement.js +1 -1
- package/lib/esm/SqliteStatement.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +10 -14
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/ViewStore.d.ts.map +1 -1
- package/lib/esm/ViewStore.js +7 -9
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js +10 -13
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js +7 -11
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
- package/lib/esm/internal/annotations/fields.js +21 -45
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -1
- package/lib/esm/internal/workspace/SettingsSchemasImpl.js +8 -7
- package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js +2 -3
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
- package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
- package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/esm/test/TestUtils.d.ts +1 -1
- package/lib/esm/test/TestUtils.d.ts.map +1 -1
- package/lib/esm/test/TestUtils.js +1 -1
- package/lib/esm/test/TestUtils.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +7 -1
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/standalone/SettingsSchemas.test.js +6 -0
- package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
- package/lib/esm/workspace/SettingsSchemas.d.ts +28 -2
- package/lib/esm/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
- package/package.json +13 -13
package/lib/esm/IModelDb.js
CHANGED
|
@@ -9,7 +9,7 @@ import * as fs from "fs";
|
|
|
9
9
|
import { join } from "path";
|
|
10
10
|
import * as touch from "touch";
|
|
11
11
|
import { assert, BeEvent, BentleyStatus, ChangeSetStatus, DbChangeStage, DbConflictCause, DbConflictResolution, DbResult, Guid, Id64, IModelStatus, JsonUtils, Logger, LogLevel, LRUMap, OpenMode } from "@itwin/core-bentley";
|
|
12
|
-
import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EditTxnError, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryRowFormat, resolveNavPropId, SchemaState, ViewStoreError, ViewStoreRpc } from "@itwin/core-common";
|
|
12
|
+
import { BriefcaseIdValue, Code, DomainOptions, ECJsNames, ECSqlReader, EditTxnError, EntityMetaData, FontMap, IModel, IModelError, IModelNotFoundResponse, ProfileOptions, QueryBinder, QueryRowFormat, resolveNavPropId, SchemaState, ViewStoreError, ViewStoreRpc } from "@itwin/core-common";
|
|
13
13
|
import { Range2d, Range3d } from "@itwin/core-geometry";
|
|
14
14
|
import { BackendLoggerCategory } from "./BackendLoggerCategory";
|
|
15
15
|
import { BriefcaseManager } from "./BriefcaseManager";
|
|
@@ -163,7 +163,7 @@ export class IModelDb extends IModel {
|
|
|
163
163
|
_schemaMap;
|
|
164
164
|
_schemaContext;
|
|
165
165
|
_schemasPromise;
|
|
166
|
-
/** @deprecated in 5.0.0 -
|
|
166
|
+
/** @deprecated in 5.0.0 - might be removed in next major version. Use [[fonts]]. */
|
|
167
167
|
_fontMap; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
168
168
|
_fonts = createIModelDbFonts(this);
|
|
169
169
|
_workspace;
|
|
@@ -238,7 +238,7 @@ export class IModelDb extends IModel {
|
|
|
238
238
|
restartDefaultTxn() {
|
|
239
239
|
this[_nativeDb].restartDefaultTxn();
|
|
240
240
|
}
|
|
241
|
-
/** @deprecated in 5.0.0 -
|
|
241
|
+
/** @deprecated in 5.0.0 - might be removed in next major version. Use [[fonts]]. */
|
|
242
242
|
get fontMap() {
|
|
243
243
|
return this._fontMap ?? (this._fontMap = new FontMap(this[_nativeDb].readFontMap())); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
244
244
|
}
|
|
@@ -521,7 +521,7 @@ export class IModelDb extends IModel {
|
|
|
521
521
|
* @returns the value returned by `callback`.
|
|
522
522
|
* @see [[withStatement]]
|
|
523
523
|
* @public
|
|
524
|
-
* @deprecated in 4.11 -
|
|
524
|
+
* @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] instead.
|
|
525
525
|
*/
|
|
526
526
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
527
527
|
withPreparedStatement(ecsql, callback, logErrors = true) {
|
|
@@ -553,7 +553,7 @@ export class IModelDb extends IModel {
|
|
|
553
553
|
* @returns the value returned by `callback`.
|
|
554
554
|
* @see [[withPreparedStatement]]
|
|
555
555
|
* @public
|
|
556
|
-
* @deprecated in 4.11 -
|
|
556
|
+
* @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] instead.
|
|
557
557
|
*/
|
|
558
558
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
559
559
|
withStatement(ecsql, callback, logErrors = true) {
|
|
@@ -774,19 +774,17 @@ export class IModelDb extends IModel {
|
|
|
774
774
|
if (typeof params.offset === "number" && params.offset > 0)
|
|
775
775
|
sql += ` OFFSET ${params.offset}`;
|
|
776
776
|
const ids = new Set();
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
if (row.id !== undefined) {
|
|
783
|
-
ids.add(row.id);
|
|
777
|
+
this.withQueryReader(sql, (reader) => {
|
|
778
|
+
for (const row of reader) {
|
|
779
|
+
const id = row[0];
|
|
780
|
+
if (id !== undefined) {
|
|
781
|
+
ids.add(id);
|
|
784
782
|
if (ids.size > IModelDb.maxLimit) {
|
|
785
783
|
throw new IModelError(IModelStatus.BadRequest, "Max LIMIT exceeded in SELECT statement");
|
|
786
784
|
}
|
|
787
785
|
}
|
|
788
786
|
}
|
|
789
|
-
});
|
|
787
|
+
}, QueryBinder.from(params.bindings));
|
|
790
788
|
return ids;
|
|
791
789
|
}
|
|
792
790
|
clearCaches(params) {
|
|
@@ -875,7 +873,7 @@ export class IModelDb extends IModel {
|
|
|
875
873
|
}
|
|
876
874
|
}
|
|
877
875
|
/** @internal
|
|
878
|
-
* @deprecated in 4.8 -
|
|
876
|
+
* @deprecated in 4.8 - might be removed in next major version. Use `txns.reverseTxns`.
|
|
879
877
|
*/
|
|
880
878
|
reverseTxns(numOperations) {
|
|
881
879
|
return this[_nativeDb].reverseTxns(numOperations);
|
|
@@ -1242,7 +1240,7 @@ export class IModelDb extends IModel {
|
|
|
1242
1240
|
}
|
|
1243
1241
|
/** The registry of entity metadata for this iModel.
|
|
1244
1242
|
* @internal
|
|
1245
|
-
* @deprecated in 5.0 -
|
|
1243
|
+
* @deprecated in 5.0 - might be removed in next major version. Use `getSchemaView()` from the `iModel` instead.
|
|
1246
1244
|
*
|
|
1247
1245
|
* @example
|
|
1248
1246
|
* ```typescript
|
|
@@ -1357,7 +1355,7 @@ export class IModelDb extends IModel {
|
|
|
1357
1355
|
* @param sql The ECSQL statement to prepare
|
|
1358
1356
|
* @param logErrors Determines if error will be logged if statement fail to prepare
|
|
1359
1357
|
* @throws [[IModelError]] if there is a problem preparing the statement.
|
|
1360
|
-
* @deprecated in 4.11 -
|
|
1358
|
+
* @deprecated in 4.11 - might be removed in next major version. Use [IModelDb.createQueryReader]($backend) or [ECDb.createQueryReader]($backend) to query.
|
|
1361
1359
|
*/
|
|
1362
1360
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
1363
1361
|
prepareStatement(sql, logErrors = true) {
|
|
@@ -1369,7 +1367,7 @@ export class IModelDb extends IModel {
|
|
|
1369
1367
|
/** Prepare an ECSQL statement.
|
|
1370
1368
|
* @param sql The ECSQL statement to prepare
|
|
1371
1369
|
* @returns `undefined` if there is a problem preparing the statement.
|
|
1372
|
-
* @deprecated in 4.11 -
|
|
1370
|
+
* @deprecated in 4.11 - might be removed in next major version. Use [IModelDb.createQueryReader]($backend) or [ECDb.createQueryReader]($backend) to query.
|
|
1373
1371
|
*/
|
|
1374
1372
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
1375
1373
|
tryPrepareStatement(sql) {
|
|
@@ -1419,7 +1417,7 @@ export class IModelDb extends IModel {
|
|
|
1419
1417
|
}
|
|
1420
1418
|
/** Get metadata for a class. This method will load the metadata from the iModel into the cache as a side-effect, if necessary.
|
|
1421
1419
|
* @throws [[IModelError]] if the metadata cannot be found nor loaded.
|
|
1422
|
-
* @deprecated in 5.0 -
|
|
1420
|
+
* @deprecated in 5.0 - might be removed in next major version. Use `getSchemaView()` on the iModel and call `view.findClass(...)` instead.
|
|
1423
1421
|
*
|
|
1424
1422
|
* @example
|
|
1425
1423
|
* * ```typescript
|
|
@@ -1446,7 +1444,7 @@ export class IModelDb extends IModel {
|
|
|
1446
1444
|
return metadata;
|
|
1447
1445
|
}
|
|
1448
1446
|
/** Identical to [[getMetaData]], except it returns `undefined` instead of throwing an error if the metadata cannot be found nor loaded.
|
|
1449
|
-
* @deprecated in 5.0 -
|
|
1447
|
+
* @deprecated in 5.0 - might be removed in next major version. Use `getSchemaView()` on the iModel and call `view.findClass(...)` instead.
|
|
1450
1448
|
*
|
|
1451
1449
|
* @example
|
|
1452
1450
|
* * ```typescript
|
|
@@ -1475,7 +1473,7 @@ export class IModelDb extends IModel {
|
|
|
1475
1473
|
* @param func The callback to be invoked on each property
|
|
1476
1474
|
* @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
|
|
1477
1475
|
* @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
|
|
1478
|
-
* @deprecated in 5.0 -
|
|
1476
|
+
* @deprecated in 5.0 - might be removed in next major version. Use `getSchemaView()` on the iModel and iterate `view.findClass(classFullName)?.getProperties()` instead.
|
|
1479
1477
|
*
|
|
1480
1478
|
* @example
|
|
1481
1479
|
* ```typescript
|
|
@@ -1502,7 +1500,7 @@ export class IModelDb extends IModel {
|
|
|
1502
1500
|
* @param func The callback to be invoked on each property
|
|
1503
1501
|
* @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
|
|
1504
1502
|
* @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
|
|
1505
|
-
* @deprecated in 5.0 -
|
|
1503
|
+
* @deprecated in 5.0 - might be removed in next major version. Use `getSchemaView()` on the iModel and iterate `view.findClass(classFullName)?.getProperties()` instead.
|
|
1506
1504
|
*
|
|
1507
1505
|
* @example
|
|
1508
1506
|
* ```typescript
|
|
@@ -1533,7 +1531,7 @@ export class IModelDb extends IModel {
|
|
|
1533
1531
|
}
|
|
1534
1532
|
/**
|
|
1535
1533
|
* @internal
|
|
1536
|
-
* @deprecated in 5.0 -
|
|
1534
|
+
* @deprecated in 5.0 - might be removed in next major version. Please use `schemaContext` from `iModel` instead to get metadata.
|
|
1537
1535
|
*/
|
|
1538
1536
|
loadMetaData(classFullName) {
|
|
1539
1537
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
@@ -1585,17 +1583,15 @@ export class IModelDb extends IModel {
|
|
|
1585
1583
|
*/
|
|
1586
1584
|
querySchemaVersionNumbers(schemaName) {
|
|
1587
1585
|
const sql = `SELECT VersionMajor,VersionWrite,VersionMinor FROM ECDbMeta.ECSchemaDef WHERE Name=:schemaName LIMIT 1`;
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
const
|
|
1593
|
-
const write = statement.getValue(1).getInteger(); // ECSchemaDef.VersionWrite --> semver.minor
|
|
1594
|
-
const minor = statement.getValue(2).getInteger(); // ECSchemaDef.VersionMinor --> semver.patch
|
|
1586
|
+
return this.withQueryReader(sql, (reader) => {
|
|
1587
|
+
if (reader.step()) {
|
|
1588
|
+
const read = reader.current[0]; // ECSchemaDef.VersionMajor --> semver.major
|
|
1589
|
+
const write = reader.current[1]; // ECSchemaDef.VersionWrite --> semver.minor
|
|
1590
|
+
const minor = reader.current[2]; // ECSchemaDef.VersionMinor --> semver.patch
|
|
1595
1591
|
return new ECVersion(read, write, minor);
|
|
1596
1592
|
}
|
|
1597
1593
|
return undefined;
|
|
1598
|
-
});
|
|
1594
|
+
}, new QueryBinder().bindString("schemaName", schemaName));
|
|
1599
1595
|
}
|
|
1600
1596
|
/** Returns true if the specified schema exists in the iModel and is no older than the specified minimum version.
|
|
1601
1597
|
* @beta
|
|
@@ -2050,14 +2046,12 @@ function processSchemaWriteStatus(status) {
|
|
|
2050
2046
|
*/
|
|
2051
2047
|
queryLastModifiedTime(modelId) {
|
|
2052
2048
|
const sql = `SELECT LastMod FROM ${Model.classFullName} WHERE ECInstanceId=:modelId`;
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
if (DbResult.BE_SQLITE_ROW === statement.step()) {
|
|
2057
|
-
return statement.getValue(0).getDateTime();
|
|
2049
|
+
return this._iModel.withQueryReader(sql, (reader) => {
|
|
2050
|
+
if (reader.step()) {
|
|
2051
|
+
return reader.current[0];
|
|
2058
2052
|
}
|
|
2059
2053
|
throw new IModelError(IModelStatus.InvalidId, `Can't get lastMod time for Model ${modelId}`);
|
|
2060
|
-
});
|
|
2054
|
+
}, new QueryBinder().bindId("modelId", modelId));
|
|
2061
2055
|
}
|
|
2062
2056
|
/** Get the Model with the specified identifier.
|
|
2063
2057
|
* @param modelId The Model identifier.
|
|
@@ -2385,13 +2379,11 @@ function processSchemaWriteStatus(status) {
|
|
|
2385
2379
|
*/
|
|
2386
2380
|
queryLastModifiedTime(elementId) {
|
|
2387
2381
|
const sql = "SELECT LastMod FROM BisCore:Element WHERE ECInstanceId=:elementId";
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
if (DbResult.BE_SQLITE_ROW === statement.step())
|
|
2392
|
-
return statement.getValue(0).getDateTime();
|
|
2382
|
+
return this._iModel.withQueryReader(sql, (reader) => {
|
|
2383
|
+
if (reader.step())
|
|
2384
|
+
return reader.current[0];
|
|
2393
2385
|
throw new IModelError(IModelStatus.InvalidId, `Can't get lastMod time for Element ${elementId}`);
|
|
2394
|
-
});
|
|
2386
|
+
}, new QueryBinder().bindId("elementId", elementId));
|
|
2395
2387
|
}
|
|
2396
2388
|
/** Create a new instance of an element.
|
|
2397
2389
|
* @param elProps The properties of the new element.
|
|
@@ -2466,15 +2458,13 @@ function processSchemaWriteStatus(status) {
|
|
|
2466
2458
|
*/
|
|
2467
2459
|
queryChildren(elementId) {
|
|
2468
2460
|
const sql = "SELECT ECInstanceId FROM BisCore:Element WHERE Parent.Id=:elementId";
|
|
2469
|
-
|
|
2470
|
-
return this._iModel.withPreparedStatement(sql, (statement) => {
|
|
2471
|
-
statement.bindId("elementId", elementId);
|
|
2461
|
+
return this._iModel.withQueryReader(sql, (reader) => {
|
|
2472
2462
|
const childIds = [];
|
|
2473
|
-
|
|
2474
|
-
childIds.push(
|
|
2463
|
+
for (const row of reader) {
|
|
2464
|
+
childIds.push(row[0]);
|
|
2475
2465
|
}
|
|
2476
2466
|
return childIds;
|
|
2477
|
-
});
|
|
2467
|
+
}, new QueryBinder().bindId("elementId", elementId));
|
|
2478
2468
|
}
|
|
2479
2469
|
/** Query for the parent of the specified element.
|
|
2480
2470
|
* @param elementId The element to check for a parent
|
|
@@ -2482,14 +2472,12 @@ function processSchemaWriteStatus(status) {
|
|
|
2482
2472
|
* @throws [[IModelError]] if the element does not exist
|
|
2483
2473
|
*/
|
|
2484
2474
|
queryParent(elementId) {
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
stmt.bindId(1, elementId);
|
|
2488
|
-
if (stmt.step() !== DbResult.BE_SQLITE_ROW)
|
|
2475
|
+
return this._iModel.withQueryReader(`select parent.id from ${Element.classFullName} where ecinstanceid=?`, (reader) => {
|
|
2476
|
+
if (!reader.step())
|
|
2489
2477
|
throw new IModelError(IModelStatus.NotFound, `Element=${elementId}`);
|
|
2490
|
-
const value =
|
|
2491
|
-
return value
|
|
2492
|
-
});
|
|
2478
|
+
const value = reader.current[0];
|
|
2479
|
+
return value ?? undefined;
|
|
2480
|
+
}, new QueryBinder().bindId(1, elementId));
|
|
2493
2481
|
}
|
|
2494
2482
|
/** Returns true if the specified Element has a sub-model.
|
|
2495
2483
|
* @see [[IModelDb.Models.getSubModel]]
|
|
@@ -2499,11 +2487,9 @@ function processSchemaWriteStatus(status) {
|
|
|
2499
2487
|
return false; // Special case since the RepositoryModel does not sub-model the root Subject
|
|
2500
2488
|
// A sub-model will have the same Id value as the element it is describing
|
|
2501
2489
|
const sql = "SELECT ECInstanceId FROM BisCore:Model WHERE ECInstanceId=:elementId";
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
return DbResult.BE_SQLITE_ROW === statement.step();
|
|
2506
|
-
});
|
|
2490
|
+
return this._iModel.withQueryReader(sql, (reader) => {
|
|
2491
|
+
return reader.step();
|
|
2492
|
+
}, new QueryBinder().bindId("elementId", elementId));
|
|
2507
2493
|
}
|
|
2508
2494
|
/** Get the root subject element. */
|
|
2509
2495
|
getRootSubject() { return this.getElement(IModel.rootSubjectId); }
|
|
@@ -2513,37 +2499,33 @@ function processSchemaWriteStatus(status) {
|
|
|
2513
2499
|
* @internal
|
|
2514
2500
|
*/
|
|
2515
2501
|
_queryAspects(elementId, fromClassFullName, excludedClassFullNames) {
|
|
2516
|
-
const sql = `SELECT ECInstanceId,ECClassId FROM ${fromClassFullName} WHERE Element.Id=:elementId ORDER BY ECClassId,ECInstanceId`; // ORDER BY to maximize statement reuse
|
|
2517
|
-
|
|
2518
|
-
return this._iModel.withPreparedStatement(sql, (statement) => {
|
|
2519
|
-
statement.bindId("elementId", elementId);
|
|
2502
|
+
const sql = `SELECT ECInstanceId, ec_classname(ECClassId, 's:c') FROM ${fromClassFullName} WHERE Element.Id=:elementId ORDER BY ECClassId,ECInstanceId`; // ORDER BY to maximize statement reuse
|
|
2503
|
+
return this._iModel.withQueryReader(sql, (reader) => {
|
|
2520
2504
|
const aspects = [];
|
|
2521
|
-
|
|
2522
|
-
const aspectInstanceId =
|
|
2523
|
-
const aspectClassFullName =
|
|
2505
|
+
for (const row of reader) {
|
|
2506
|
+
const aspectInstanceId = row[0];
|
|
2507
|
+
const aspectClassFullName = row[1];
|
|
2524
2508
|
if ((undefined === excludedClassFullNames) || (!excludedClassFullNames.has(aspectClassFullName))) {
|
|
2525
2509
|
aspects.push(this._queryAspect(aspectInstanceId, aspectClassFullName));
|
|
2526
2510
|
}
|
|
2527
2511
|
}
|
|
2528
2512
|
return aspects;
|
|
2529
|
-
});
|
|
2513
|
+
}, new QueryBinder().bindId("elementId", elementId));
|
|
2530
2514
|
}
|
|
2531
2515
|
/** Query for aspect by ECInstanceId
|
|
2532
2516
|
* @throws [[IModelError]]
|
|
2533
2517
|
*/
|
|
2534
2518
|
_queryAspect(aspectInstanceId, aspectClassName) {
|
|
2535
|
-
const sql = `SELECT
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
const aspectProps = statement.getRow(); // start with everything that SELECT * returned
|
|
2541
|
-
aspectProps.classFullName = aspectProps.className.replace(".", ":"); // add in property required by EntityProps
|
|
2542
|
-
aspectProps.className = undefined; // clear property from SELECT * that we don't want in the final instance
|
|
2519
|
+
const sql = `SELECT *, ec_classname(ECClassId, 's:c') classFullName FROM ${aspectClassName} WHERE ECInstanceId=:aspectInstanceId`;
|
|
2520
|
+
const aspect = this._iModel.withQueryReader(sql, (reader) => {
|
|
2521
|
+
if (reader.step()) {
|
|
2522
|
+
const aspectProps = { ...reader.current.toRow() }; // start with everything that SELECT * returned; classFullName is supplied by the ec_classname alias
|
|
2523
|
+
aspectProps.className = undefined; // clear the raw ECClassId-derived property from SELECT * that we don't want in the final instance
|
|
2543
2524
|
return aspectProps;
|
|
2544
2525
|
}
|
|
2545
2526
|
return undefined;
|
|
2546
|
-
|
|
2527
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
2528
|
+
}, new QueryBinder().bindId("aspectInstanceId", aspectInstanceId), { rowFormat: QueryRowFormat.UseJsPropertyNames });
|
|
2547
2529
|
if (undefined === aspect) {
|
|
2548
2530
|
throw new IModelError(IModelStatus.NotFound, `ElementAspect not found ${aspectInstanceId}, ${aspectClassName}`);
|
|
2549
2531
|
}
|
|
@@ -2553,12 +2535,10 @@ function processSchemaWriteStatus(status) {
|
|
|
2553
2535
|
* @throws [[IModelError]]
|
|
2554
2536
|
*/
|
|
2555
2537
|
getAspect(aspectInstanceId) {
|
|
2556
|
-
const sql = "SELECT ECClassId FROM BisCore:ElementAspect WHERE ECInstanceId=:aspectInstanceId";
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
return (DbResult.BE_SQLITE_ROW === statement.step()) ? statement.getValue(0).getClassNameForClassId().replace(".", ":") : undefined;
|
|
2561
|
-
});
|
|
2538
|
+
const sql = "SELECT ec_classname(ECClassId, 's:c') FROM BisCore:ElementAspect WHERE ECInstanceId=:aspectInstanceId";
|
|
2539
|
+
const aspectClassFullName = this._iModel.withQueryReader(sql, (reader) => {
|
|
2540
|
+
return reader.step() ? reader.current[0] : undefined;
|
|
2541
|
+
}, new QueryBinder().bindId("aspectInstanceId", aspectInstanceId));
|
|
2562
2542
|
if (undefined === aspectClassFullName) {
|
|
2563
2543
|
throw new IModelError(IModelStatus.NotFound, `ElementAspect not found ${aspectInstanceId}`);
|
|
2564
2544
|
}
|
|
@@ -2566,13 +2546,12 @@ function processSchemaWriteStatus(status) {
|
|
|
2566
2546
|
}
|
|
2567
2547
|
static classMap = new Map();
|
|
2568
2548
|
runInstanceQuery(sql, elementId, excludedClassFullNames) {
|
|
2569
|
-
|
|
2570
|
-
return this._iModel.withPreparedStatement(sql, (statement) => {
|
|
2571
|
-
statement.bindId("elementId", elementId);
|
|
2549
|
+
return this._iModel.withQueryReader(sql, (reader) => {
|
|
2572
2550
|
const aspects = [];
|
|
2573
|
-
|
|
2551
|
+
for (const queryRow of reader) {
|
|
2574
2552
|
const row = {};
|
|
2575
|
-
const
|
|
2553
|
+
const rawInstance = queryRow[0];
|
|
2554
|
+
const parsedRow = typeof rawInstance === "string" ? JSON.parse(rawInstance) : rawInstance;
|
|
2576
2555
|
// eslint-disable-next-line guard-for-in
|
|
2577
2556
|
for (const key in parsedRow) {
|
|
2578
2557
|
const jsName = ECJsNames.toJsName(key[0].toUpperCase() + key.substring(1));
|
|
@@ -2585,7 +2564,7 @@ function processSchemaWriteStatus(status) {
|
|
|
2585
2564
|
aspects.push(this._iModel.constructEntity(aspectProps));
|
|
2586
2565
|
}
|
|
2587
2566
|
return aspects;
|
|
2588
|
-
});
|
|
2567
|
+
}, new QueryBinder().bindId("elementId", elementId));
|
|
2589
2568
|
}
|
|
2590
2569
|
/** Get the ElementAspect instances that are owned by the specified element.
|
|
2591
2570
|
* @param elementId Get ElementAspects associated with this Element
|
|
@@ -2616,14 +2595,15 @@ function processSchemaWriteStatus(status) {
|
|
|
2616
2595
|
let classIdList = IModelDb.Elements.classMap.get(aspectClassFullName);
|
|
2617
2596
|
if (classIdList === undefined) {
|
|
2618
2597
|
const classIds = [];
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2598
|
+
const sql = `select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name=:className
|
|
2599
|
+
and Schema.Id = (select ECInstanceId from meta.ECSchemaDef where Name=:schemaName)) and SourceECInstanceId != TargetECInstanceId`;
|
|
2600
|
+
this._iModel.withQueryReader(sql, (reader) => {
|
|
2601
|
+
for (const row of reader) {
|
|
2602
|
+
classIds.push(row[0]);
|
|
2603
|
+
}
|
|
2604
|
+
}, new QueryBinder()
|
|
2605
|
+
.bindString("className", fullClassName[1])
|
|
2606
|
+
.bindString("schemaName", fullClassName[0]));
|
|
2627
2607
|
if (classIds.length > 0) {
|
|
2628
2608
|
classIdList = classIds.join(",");
|
|
2629
2609
|
IModelDb.Elements.classMap.set(aspectClassFullName, classIdList);
|
|
@@ -2875,7 +2855,7 @@ function processSchemaWriteStatus(status) {
|
|
|
2875
2855
|
}
|
|
2876
2856
|
/** Set the default view property the iModel.
|
|
2877
2857
|
* @param viewId The Id of the ViewDefinition to use as the default
|
|
2878
|
-
* @deprecated in 4.2.0 -
|
|
2858
|
+
* @deprecated in 4.2.0 - might be removed in next major version. Avoid setting this property - it is not practical for one single view to serve the needs of the many applications
|
|
2879
2859
|
* that might wish to view the contents of the iModel.
|
|
2880
2860
|
*/
|
|
2881
2861
|
setDefaultViewId(viewId) {
|