Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.queryFilterQueryinvoke

invoke

abstract operator fun <V> Field<T, V>.invoke(block: FilterQueryPredicate<V>.() -> Unit)

Targets a single field to execute a targeted predicate.

Example

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

collection.find {
    User::name {
        eq("foo")
    }
}

Note that many operators available this way have a convenience function directly in this class to shorten this. For this example, see eq:

collection.find {
    User::name eq "foo"
}
open operator fun <V> KProperty1<T, V>.invoke(block: FilterQueryPredicate<V>.() -> Unit)

Targets a single field to execute a targeted predicate.

Example

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

collection.find {
    User::name {
        eq("foo")
    }
}

Note that many operators available this way have a convenience function directly in this class to shorten this. For this example, see eq:

collection.find {
    User::name eq "foo"
}