Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.queryFilterQueryisNotEmpty

isNotEmpty

open fun Field<T, Collection<*>>.isNotEmpty()

Matches documents in which an array is not empty.

Example

Return all users that have one or more grades.

class User(
    val name: String?,
    val grades: List<Int>
)

collection.find {
    User::grades.isNotEmpty()
}

See also

open fun KProperty1<T, Collection<*>>.isNotEmpty()

Matches documents in which an array is not empty.

Example

Return all users that have one or more grades.

class User(
    val name: String?,
    val grades: List<Int>
)

collection.find {
    User::grades.isNotEmpty()
}

See also