Skip to content

where

const where: object

Defined in: packages/schema/src/filter/where.ts:123

Builds a filter in code instead of writing filter text, for any resource; createWhere checks names and values against one. The Filters of the API take what it builds.

ago: (duration) => FilterValue

A time the duration before now, such as ago('7d') for now() - 7d; units are s, m, h, d and w.

string

FilterValue

and: (…args) => FilterExpr

Every filter holds; one filter is returned as it is, none throws.

…FilterExpr[]

FilterExpr

between: <K>(name, low, high) => FilterExpr

The field lies from low to high, both included.

K extends string

K

any

any

FilterExpr

eq: <K>(name, value) => FilterExpr

The field equals the value: status = "paid".

K extends string

K

any

FilterExpr

fromNow: (duration) => FilterValue

A time the duration after now, such as fromNow('1h') for now() + 1h.

string

FilterValue

gt: <K>(name, value) => FilterExpr

The field is above the value: total > 100.

K extends string

K

any

FilterExpr

gte: <K>(name, value) => FilterExpr

The field is at least the value: total >= 100.

K extends string

K

any

FilterExpr

has: <K>(name, value) => FilterExpr

A JSON field holds the value, as a key or an element: tags:"urgent".

K extends string

K

string | number | false | true

FilterExpr

in: <K>(name, values) => FilterExpr

The field equals one of the values: in(status, "paid", "sent").

K extends string

K

any[]

FilterExpr

isNull: <K>(name) => FilterExpr

The field has no value: isNull(field).

K extends string

K

FilterExpr

lt: <K>(name, value) => FilterExpr

The field is below the value: total < 100.

K extends string

K

any

FilterExpr

lte: <K>(name, value) => FilterExpr

The field is at most the value: total <= 100.

K extends string

K

any

FilterExpr

ne: <K>(name, value) => FilterExpr

The field differs from the value: status != "paid".

K extends string

K

any

FilterExpr

not: (arg) => FilterExpr

The filter does not hold.

FilterExpr

FilterExpr

now: () => FilterValue

The current time, as a value to compare with: now().

FilterValue

or: (…args) => FilterExpr

At least one filter holds; one filter is returned as it is, none throws.

…FilterExpr[]

FilterExpr

present: <K>(name) => FilterExpr

The field has a value, a JSON field one other than null: field:*.

K extends string

K

FilterExpr

regex: <K>(name, pattern) => FilterExpr

The text field matches the regular expression, ignoring case: regex(field, "pattern").

K extends string

K

string

FilterExpr

search: (text) => FilterExpr

Every word of the text appears, ignoring case, in one of the resource’s search fields: search("text").

string

FilterExpr

similar: <K>(name, text) => FilterExpr

The text field is close to the text by trigram similarity, typos included: similar(field, "text").

K extends string

K

string

FilterExpr

where.and(where.eq('status', 'paid'), where.gte('created_at', where.ago('30d')))