FilterQueryPredicate

DSL for MongoDB operators that are used as predicates in conditions in a context where the targeted field is already specified.

Example

class User(
val name: String?,
val age: Int,
)

collection.find {
User::name { //(1)
eq("foo")
}
}
  1. By referring to a specific property, we obtain a FilterQueryPredicate that we can use to declare many operators on that property.

If you can't find the operator you're searching for, visit the tracking issue.

External resources

Parameters

T

The type on which this predicate applies. For example, if the selected field is of type String, then T is String.

Properties

Link copied to clipboard
abstract val context: <Error class: unknown class>

The context used to generate this expression.

Link copied to clipboard

Converts a Kotlin property into a Field.

Functions

Link copied to clipboard
abstract override fun accept(node: BsonNode)

Adds a new node as a child of this one.

Link copied to clipboard
fun <N : Node> CompoundNode<N>.acceptAll(nodes: Iterable<N>)

Adds any number of nodes into this one.

Link copied to clipboard
abstract fun bitsAllClear(mask: <Error class: unknown class>)
abstract fun bitsAllClear(mask: ByteArray)

Matches documents where all bit positions present in mask are clear (i.e., 0) in the current field.

Link copied to clipboard
abstract fun bitsAllSet(mask: <Error class: unknown class>)
abstract fun bitsAllSet(mask: ByteArray)

Matches documents where all bit positions present in mask are set (i.e., 1) in the current field.

Link copied to clipboard
abstract fun bitsAnyClear(mask: <Error class: unknown class>)
abstract fun bitsAnyClear(mask: ByteArray)

Matches documents where any bit position present in mask is clear (i.e., 0) in the current field.

Link copied to clipboard
abstract fun bitsAnySet(mask: <Error class: unknown class>)
abstract fun bitsAnySet(mask: ByteArray)

Matches documents where any bit position present in mask is set (i.e., 1) in the current field.

Link copied to clipboard
open operator fun <Root, Parent, Child> KProperty1<Root, Parent>.div(child: KProperty1<Parent & Any, Child>): Field<Root, Child>

Refers to child as a nested field of the current field.

Link copied to clipboard
abstract fun doesNotExist()

Matches documents that do not contain the specified field. Documents where the field if null are counted as existing.

Link copied to clipboard
abstract fun eq(value: T)

Matches documents where the value of a field equals the value.

Link copied to clipboard
open fun eqNotNull(value: T?)

Matches documents where the value of a field equals value.

Link copied to clipboard
abstract fun exists()

Matches documents that contain the specified field, including values where the field value is null.

Link copied to clipboard
abstract override fun freeze()

Makes this expression immutable.

Link copied to clipboard
open operator fun <Root, Type> KProperty1<Root, Collection<Type>>.get(index: Int): Field<Root, Type>

Refers to a specific item in an array, by its index.

open operator fun <Root, Type> KProperty1<Root, Map<String, Type>>.get(index: String): Field<Root, Type>

Refers to a specific item in a map, by its name.

Link copied to clipboard
abstract fun gt(value: T)

Selects documents for which this field has a value strictly greater than value.

Link copied to clipboard
abstract fun gte(value: T)

Selects documents for which this field has a value greater or equal to value.

Link copied to clipboard
open fun gteNotNull(value: T?)

Selects documents for which this field has a value greater or equal to value.

Link copied to clipboard
open fun gtNotNull(value: T?)

Selects documents for which this field has a value strictly greater than value.

Link copied to clipboard
abstract fun hasType(type: <Error class: unknown class>)

Selects documents where the value of the field is an instance of the specified BSON type.

Link copied to clipboard
open fun isNotNull()

Selects documents for which the field is not null.

Link copied to clipboard
open fun isNotOneOf(vararg values: T)
abstract fun isNotOneOf(values: Collection<T>)

Selects documents for which this field is not equal to any of the given values.

Link copied to clipboard
open fun isNotUndefined()

Selects documents for which the field is not undefined.

Link copied to clipboard
open fun isNull()

Selects documents for which the field is null.

Link copied to clipboard
open fun isOneOf(vararg values: T)
abstract fun isOneOf(values: Collection<T>)

Selects documents for which this field is equal to one of the given values.

Link copied to clipboard
open fun isUndefined()

Selects documents for which the field is undefined.

Link copied to clipboard
abstract fun lt(value: T)

Selects documents for which this field has a value strictly lesser than value.

Link copied to clipboard
abstract fun lte(value: T)

Selects documents for which this field has a value lesser or equal to value.

Link copied to clipboard
open fun lteNotNull(value: T?)

Selects documents for which this field has a value lesser or equal to value.

Link copied to clipboard
open fun ltNotNull(value: T?)

Selects documents for which this field has a value strictly lesser than value.

Link copied to clipboard
abstract fun ne(value: T)

Matches documents where the value of a field does not equal the value.

Link copied to clipboard
abstract fun not(expression: FilterQueryPredicate<T>.() -> Unit)

Performs a logical NOT operation on the specified expression and selects the documents that do not match the expression. This includes the elements that do not contain the field.

Link copied to clipboard
abstract fun regex(pattern: String, caseInsensitive: Boolean = false, dotAll: Boolean = false, extended: Boolean = false, matchEachLine: Boolean = false)

Matches documents where the field corresponds to a given regex expression.

Link copied to clipboard
abstract fun simplify(): BsonNode?

Returns a simplified (but equivalent) expression to the current expression.

Link copied to clipboard
open fun toBson(): <Error class: unknown class>

Writes the result of simplifying to a new Bson.

Link copied to clipboard
abstract override fun toString(): String

JSON representation of this expression.

Link copied to clipboard
abstract fun writeTo(writer: <Error class: unknown class>)

Writes the result of simplifying this expression into writer.