API reference > @kontsedal/olas-core > createQuery
createQuery() function
Subscribe this controller to a shared cache entry (§5.2).
ts
const user = createQuery(ctx, userQuery, () => [userId.value])Needs a query engine on the root:createRoot(def, { deps, queries: queryEngine() }).
With options.select, the subscription reports select(data). The projection runs per subscriber, and the cache keeps the raw value.
Signature:
typescript
export declare function createQuery<Args extends unknown[], T, U>(ctx: Ctx, source: Query<Args, T>, options: QuerySelectOptions<readonly [...Args], T, U>): QuerySubscription<U>;Parameters
Parameter | Type | Description |
|---|---|---|
ctx | ||
source | Query<Args, T> | |
options | QuerySelectOptions<readonly [...Args], T, U> |
Returns: