Skip to content

printFilter

printFilter(ast): string

Defined in: packages/schema/src/filter/print.ts:6

Canonical text, readable by parseFilter; OR groups inside AND are always parenthesised. A checked filter prints its fields by name.

{ kind: "search"; span: Span; text: string; } | { args: FilterOf<FieldModel, never>[]; kind: "and"; span: Span; } | { args: FilterOf<FieldModel, never>[]; kind: "or"; span: Span; } | { arg: FilterOf<FieldModel, never>; kind: "not"; span: Span; } | { field: FieldModel; kind: "compare"; op: CompareOp; span: Span; value: FilterValue; } | { field: FieldModel; kind: "has"; span: Span; value: Literal; } | { field: FieldModel; kind: "present"; span: Span; } | { field: FieldModel; kind: "in"; span: Span; values: Literal[]; } | { field: FieldModel; kind: "similar"; span: Span; text: string; } | { field: FieldModel; kind: "regex"; pattern: string; span: Span; } | { field: FieldModel; kind: "isNull"; span: Span; } | RelatedFilter | { args: FilterOf<FieldPath, RelatedFilter>[]; kind: "and"; span: Span; } | { args: FilterOf<FieldPath, RelatedFilter>[]; kind: "or"; span: Span; } | { arg: FilterOf<FieldPath, RelatedFilter>; kind: "not"; span: Span; } | { field: FieldPath; kind: "compare"; op: CompareOp; span: Span; value: FilterValue; } | { field: FieldPath; kind: "has"; span: Span; value: Literal; } | { field: FieldPath; kind: "present"; span: Span; } | { field: FieldPath; kind: "in"; span: Span; values: Literal[]; } | { field: FieldPath; kind: "similar"; span: Span; text: string; } | { field: FieldPath; kind: "regex"; pattern: string; span: Span; } | { field: FieldPath; kind: "isNull"; span: Span; }

{ kind: "search"; span: Span; text: string; }

"search"

search("text") or bare words: every word appears in one of the resource’s search fields.

Span

Where it stands in the filter text.

string

The text searched for.


{ args: FilterOf<FieldModel, never>[]; kind: "and"; span: Span; }

FilterOf<FieldModel, never>[]

The filters joined.

"and"

Every one of args holds (AND).

Span

Where it stands in the filter text.


{ args: FilterOf<FieldModel, never>[]; kind: "or"; span: Span; }

FilterOf<FieldModel, never>[]

The filters joined.

"or"

One of args holds (OR).

Span

Where it stands in the filter text.


{ arg: FilterOf<FieldModel, never>; kind: "not"; span: Span; }

FilterOf<FieldModel, never>

The filter negated.

"not"

arg does not hold (NOT, -).

Span

Where it stands in the filter text.


{ field: FieldModel; kind: "compare"; op: CompareOp; span: Span; value: FilterValue; }

FieldModel

The field compared.

"compare"

A comparison of a field with a value.

CompareOp

The comparison.

Span

Where it stands in the filter text.

FilterValue

What it is compared with.


{ field: FieldModel; kind: "has"; span: Span; value: Literal; }

FieldModel

The field.

"has"

field:value: a JSON field holds the value as a key or element.

Span

Where it stands in the filter text.

Literal

The value it holds.


{ field: FieldModel; kind: "present"; span: Span; }

FieldModel

The field.

"present"

field:*: the field has a value.

Span

Where it stands in the filter text.


{ field: FieldModel; kind: "in"; span: Span; values: Literal[]; }

FieldModel

The field.

"in"

in(field, v, ...): the field equals one of the values.

Span

Where it stands in the filter text.

Literal[]

The values.


{ field: FieldModel; kind: "similar"; span: Span; text: string; }

FieldModel

The field.

"similar"

similar(field, "text"): the field is like the text, by pg_trgm similarity.

Span

Where it stands in the filter text.

string

The text it is compared with.


{ field: FieldModel; kind: "regex"; pattern: string; span: Span; }

FieldModel

The field.

"regex"

regex(field, "pattern"): the field matches the regular expression.

string

The regular expression.

Span

Where it stands in the filter text.


{ field: FieldModel; kind: "isNull"; span: Span; }

FieldModel

The field.

"isNull"

isNull(field): the field has no value.

Span

Where it stands in the filter text.


RelatedFilter


{ args: FilterOf<FieldPath, RelatedFilter>[]; kind: "and"; span: Span; }

FilterOf<FieldPath, RelatedFilter>[]

The filters joined.

"and"

Every one of args holds (AND).

Span

Where it stands in the filter text.


{ args: FilterOf<FieldPath, RelatedFilter>[]; kind: "or"; span: Span; }

FilterOf<FieldPath, RelatedFilter>[]

The filters joined.

"or"

One of args holds (OR).

Span

Where it stands in the filter text.


{ arg: FilterOf<FieldPath, RelatedFilter>; kind: "not"; span: Span; }

FilterOf<FieldPath, RelatedFilter>

The filter negated.

"not"

arg does not hold (NOT, -).

Span

Where it stands in the filter text.


{ field: FieldPath; kind: "compare"; op: CompareOp; span: Span; value: FilterValue; }

FieldPath

The field compared.

"compare"

A comparison of a field with a value.

CompareOp

The comparison.

Span

Where it stands in the filter text.

FilterValue

What it is compared with.


{ field: FieldPath; kind: "has"; span: Span; value: Literal; }

FieldPath

The field.

"has"

field:value: a JSON field holds the value as a key or element.

Span

Where it stands in the filter text.

Literal

The value it holds.


{ field: FieldPath; kind: "present"; span: Span; }

FieldPath

The field.

"present"

field:*: the field has a value.

Span

Where it stands in the filter text.


{ field: FieldPath; kind: "in"; span: Span; values: Literal[]; }

FieldPath

The field.

"in"

in(field, v, ...): the field equals one of the values.

Span

Where it stands in the filter text.

Literal[]

The values.


{ field: FieldPath; kind: "similar"; span: Span; text: string; }

FieldPath

The field.

"similar"

similar(field, "text"): the field is like the text, by pg_trgm similarity.

Span

Where it stands in the filter text.

string

The text it is compared with.


{ field: FieldPath; kind: "regex"; pattern: string; span: Span; }

FieldPath

The field.

"regex"

regex(field, "pattern"): the field matches the regular expression.

string

The regular expression.

Span

Where it stands in the filter text.


{ field: FieldPath; kind: "isNull"; span: Span; }

FieldPath

The field.

"isNull"

isNull(field): the field has no value.

Span

Where it stands in the filter text.

string