FilterQueryBuilder

Infix DSL for building filter queries.

Each operation appends a filter_query[<field>][<operation>]=<value> parameter, naming the field by a property reference of T resolved to its serialized name. Collection values are joined with commas, as the API expects.

The operations do not constrain the property's Kotlin type: Storyblok serializes numbers as JSON strings, so a numeric field is as likely to be modelled as a String as a Double, and requiring one would rule out valid schemas. The comparison operations are the exception — they check the field can hold the operand they are given.

A property reference addresses one of T's own fields, so nested blocks and fields — which the API addresses with a dotted path, seo.description or body.0.name — have no entry point here, and a reference to the containing field alone filters on the whole object rather than on a property inside it. Write those out with Query.parameter:

parameter("filter_query[seo.description][is]", "not_empty")

Type Parameters

T

The Component type the enclosing query is built for.

Functions

Link copied to clipboard
infix fun KProperty1<in T, *>.allIn(values: Collection<String>)

all_in_array: the array field contains all of the given values.

Link copied to clipboard
infix fun KProperty1<in T, *>.anyIn(values: Collection<String>)

any_in_array: the array field contains any of the given values.

Link copied to clipboard
infix fun KProperty1<in T, *>.greaterThan(value: Double)

gt_float: the float field value is greater than the given value. Applies to values written with a decimal point, whether the field is a number field or a text field.

infix fun KProperty1<in T, *>.greaterThan(value: Long)

gt_int: the integer field value is greater than the given value. Applies to values written without a decimal point, whether the field is a number field or a text field.

infix fun KProperty1<in T, *>.greaterThan(value: Instant)

gt_date: the date field value is after the given instant.

Link copied to clipboard
infix fun KProperty1<in T, *>.is(value: Is)

is: the field value is of the given value type.

Link copied to clipboard
infix fun KProperty1<in T, *>.isIn(values: Collection<String>)

in: the field value matches any of the given values.

Link copied to clipboard
infix fun KProperty1<in T, *>.lessThan(value: Double)

lt_float: the float field value is less than the given value. Applies to values written with a decimal point, whether the field is a number field or a text field.

infix fun KProperty1<in T, *>.lessThan(value: Long)

lt_int: the integer field value is less than the given value. Applies to values written without a decimal point, whether the field is a number field or a text field.

infix fun KProperty1<in T, *>.lessThan(value: Instant)

lt_date: the date field value is before the given instant.

Link copied to clipboard
infix fun KProperty1<in T, *>.like(pattern: String)

like: the field value matches the given pattern (supports * wildcards).

Link copied to clipboard
infix fun KProperty1<in T, *>.notIn(values: Collection<String>)

not_in: the field value matches none of the given values.

Link copied to clipboard
infix fun KProperty1<in T, *>.notLike(pattern: String)

not_like: the field value does not match the given pattern.