@itwin/core-backend 5.14.0-dev.21 → 5.14.0-dev.22
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/lib/cjs/ECDb.d.ts +11 -6
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +11 -6
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +2 -2
- package/lib/cjs/ECSqlStatement.js +2 -2
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +12 -10
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +19 -12
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/esm/ECDb.d.ts +11 -6
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +11 -6
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +2 -2
- package/lib/esm/ECSqlStatement.js +2 -2
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +12 -10
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +19 -12
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +105 -30
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/package.json +13 -13
package/lib/esm/IModelDb.js
CHANGED
|
@@ -615,17 +615,18 @@ export class IModelDb extends IModel {
|
|
|
615
615
|
throw err;
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
/**
|
|
618
|
+
/** Creates a reader for asynchronous ECSQL query execution.
|
|
619
|
+
* Execution starts when the reader is consumed using asynchronous iteration or awaited calls to `step()` or `toArray()`.
|
|
620
|
+
* Results are fetched and buffered in batches. For synchronous, callback-scoped execution, use [[withQueryReader]].
|
|
619
621
|
*
|
|
620
622
|
* See also:
|
|
621
|
-
* - [
|
|
622
|
-
* - [
|
|
623
|
+
* - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)
|
|
624
|
+
* - [Asynchronous query examples]($docs/learning/ECSQLCodeExamples)
|
|
623
625
|
* - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)
|
|
624
626
|
*
|
|
625
627
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
626
628
|
* @param config Allow to specify certain flags which control how query is executed.
|
|
627
629
|
* @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.
|
|
628
|
-
* Should be used when we donot want true step by step behaviour and want to take advantage of caching capabilities of the reader.
|
|
629
630
|
* @public
|
|
630
631
|
* */
|
|
631
632
|
createQueryReader(ecsql, params, config) {
|
|
@@ -638,20 +639,21 @@ export class IModelDb extends IModel {
|
|
|
638
639
|
};
|
|
639
640
|
return new ECSqlReader(executor, ecsql, params, config);
|
|
640
641
|
}
|
|
641
|
-
/**
|
|
642
|
+
/** Executes a callback with a synchronous ECSQL reader on the owning database connection.
|
|
643
|
+
* The reader steps one row at a time without buffering result batches. Finish using it before the callback completes.
|
|
644
|
+
* Return materialized rows or computed values rather than the reader. For asynchronous execution, use [[createQueryReader]].
|
|
645
|
+
* The prepared statement may be reused from the statement cache between completed calls.
|
|
642
646
|
*
|
|
643
647
|
* See also:
|
|
644
|
-
* - [
|
|
645
|
-
* - [
|
|
648
|
+
* - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)
|
|
649
|
+
* - [Synchronous query examples]($docs/learning/backend/WithQueryReaderCodeExamples)
|
|
646
650
|
* - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)
|
|
647
651
|
* @param ecsql The ECSQL query to execute.
|
|
648
|
-
* @param callback the callback to invoke on the prepared
|
|
652
|
+
* @param callback the callback to invoke on the prepared ECSqlSyncReader
|
|
649
653
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
650
654
|
* @param config Allow to specify certain flags which control how query is executed.
|
|
651
655
|
* @returns the value returned by `callback`.
|
|
652
656
|
* @throws IModelError if db is not open.
|
|
653
|
-
* Use this method for true step-by-step row consumption without intermediate result or page caching.
|
|
654
|
-
* The prepared ECSQL statement may be reused from the statement cache between completed calls.
|
|
655
657
|
* @beta
|
|
656
658
|
* */
|
|
657
659
|
withQueryReader(ecsql, callback, params, config) {
|
|
@@ -1413,7 +1415,10 @@ export class IModelDb extends IModel {
|
|
|
1413
1415
|
const result = await reader.next();
|
|
1414
1416
|
if (result.done)
|
|
1415
1417
|
throw new IModelError(DbResult.BE_SQLITE_ERROR, "PRAGMA checksum(schema_token) returned no rows");
|
|
1416
|
-
|
|
1418
|
+
const token = result.value.sha3_256;
|
|
1419
|
+
if (typeof token !== "string")
|
|
1420
|
+
throw new IModelError(DbResult.BE_SQLITE_ERROR, "PRAGMA checksum(schema_token) returned an invalid sha3_256 column");
|
|
1421
|
+
return token;
|
|
1417
1422
|
},
|
|
1418
1423
|
};
|
|
1419
1424
|
}
|
|
@@ -1432,7 +1437,9 @@ export class IModelDb extends IModel {
|
|
|
1432
1437
|
const token = result.value.schemaToken;
|
|
1433
1438
|
if (data === undefined || data === null)
|
|
1434
1439
|
throw new IModelError(DbResult.BE_SQLITE_ERROR, `${pragma} returned null data column`);
|
|
1435
|
-
|
|
1440
|
+
if (typeof token !== "string")
|
|
1441
|
+
throw new IModelError(DbResult.BE_SQLITE_ERROR, `${pragma} returned an invalid schemaToken column`);
|
|
1442
|
+
return { data, schemaToken: token };
|
|
1436
1443
|
}
|
|
1437
1444
|
/** Get the linkTableRelationships for this IModel */
|
|
1438
1445
|
get relationships() {
|