Μετάβαση στο περιεχόμενο

QueryBus

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

Defined in: packages/cqrs/src/query.bus.ts:18

Sends a query to its one handler, through the handler’s pipeline. createCqrs() builds it.

const { queryBus } = createCqrs();
const user = await queryBus.execute<GetUserQuery, User | null>(new GetUserQuery('u-1'));

Q extends IQuery = IQuery

new QueryBus<Q>(handlers): QueryBus<Q>

Defined in: packages/cqrs/src/query.bus.ts:24

ReadonlyMap<AnyClass, Dispatch>

Maps each query class to the function that runs its handler. The bus reads it at every call, so it can be filled after the bus is created, as handlers that inject the bus require.

QueryBus<Q>

execute<T, R>(query): Promise<R>

Defined in: packages/cqrs/src/query.bus.ts:37

Runs the handler of the query’s class, or of its nearest parent class that has one, and resolves with what the handler returns, typed as R.

T extends IQuery

R = unknown

T

Promise<R>

QueryHandlerNotFoundException (as a rejection) when no class in the query’s chain has a handler.

await queryBus.execute(new GetUserQuery('u-1'));