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

createQuery

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

createQuery<TSchema, TBase>(schema, Base?): ZodQueryClass<TSchema, TBase>

Defined in: packages/pipeline-zod/src/create-zod-request.ts:294

Generates a strongly-typed CQRS Query class from a Zod schema.

Automatically marks the class with requestKind = 'query', attaches the Zod schema as static _zodSchema, forwards Standard Schema metadata (~standard), and preserves the prototype and constructor arguments of an optional base class.

TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

TBase extends AbstractConstructor<object> = AbstractConstructor<object>

TSchema

TBase

ZodQueryClass<TSchema, TBase>

Defining a Query with a base class

abstract class AppQuery {
constructor(readonly actorId?: string) {}
}
const GetUserSchema = z.object({ id: z.uuid() });
export class GetUserQuery extends createQuery(GetUserSchema, AppQuery) {}