Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.queryFilterQuerynot

not

open infix fun <V> Field<T, V>.not(expression: FilterQueryPredicate<V>.() -> 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.

Example

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

collection.find {
    User::age not {
        hasType(BsonType.STRING)
    }
}

External resources

open infix fun <V> KProperty1<T, V>.not(expression: FilterQueryPredicate<V>.() -> 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.

Example

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

collection.find {
    User::age not {
        hasType(BsonType.STRING)
    }
}

External resources