@cbnsndwch/zero-sources

QueryArg() function

Home > @cbnsndwch/nest-zero-synced-queries > QueryArg

QueryArg() function

Parameter decorator to inject a query argument by index.

Use this decorator to explicitly map query arguments to method parameters.

Signature:

export declare function QueryArg(index: number): ParameterDecorator;

Parameters

Parameter

Type

Description

index

number

The index of the argument in the query args array

Returns:

ParameterDecorator

Remarks

  • Useful when mixing authenticated and query parameters - Makes parameter mapping explicit - Can skip parameters if not needed

Example

@SyncedQuery('search', z.tuple([z.string(), z.number()]))
async search(
  @CurrentUser() user: JwtPayload,
  @QueryArg(0) query: string,
  @QueryArg(1) limit: number
) {
  // query = args[0], limit = args[1]
}

How was this page?