Skip to content

querySyntax

querySyntax<T>(entitySchema, options?): TObject

Defined in: query-syntax.ts:24

Derive a query schema from an entity schema, following the RepositoryService query convention (Phase 4 TDD §14): every entity field accepts either a bare value or an operator object ($gt/$gte/$lt/$lte/$ne/$in/$nin, plus $like/$notlike/ $ilike for string fields), and the reserved keys $limit, $skip, $sort, $select, $or, $and are typed to match. Unknown keys are rejected (additionalProperties: false).

Use it with the validate hook on the query target:

app.service("users").hooks({
before: { find: [validate(querySyntax(userSchema), { target: "query", coerce: true })] },
});

T extends TObject<TProperties>

T

QuerySyntaxOptions = {}

TObject