Unified API to execute ECSQL query on an iModel, working on both frontend and backend? #9326
-
|
Hi, I am writing a utility package that needs to execute ECSQL queries on an iModel. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @AlexandreWalensa. The @iTwin/itwinjs-core-presentation team had the same issue, here's what we came up with:
|
Beta Was this translation helpful? Give feedback.
Hi @AlexandreWalensa. The @iTwin/itwinjs-core-presentation team had the same issue, here's what we came up with:
The signature of
createQueryReaderfunction onIModelDbandIModelConnectionis exactly the same, so you can create a type that defines an object with this function, and then bothIModelDbandIModelConnectionwill meet the type's requirement. Here's how we typed it: https://github.com/iTwin/presentation/blob/6f3464afefe54aeccbe72e51084566f88abac1c5/packages/core-interop/src/core-interop/QueryExecutor.ts#L26.Going a step further (which you may not need), we wanted to avoid a dependency on
@itwin/core-common, so we created our own type for a query reader and mapped core's r…