kmongo / org.litote.kmongo / kotlin.reflect.KProperty / contains

contains

infix fun <T> KProperty<Iterable<T?>?>.contains(value: T?): Bson (source)

Creates a filter that matches all documents where the value of the property contains the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.

Please be aware that although can be any object, using this method to find documents matching complex object is extremely fragile. In particular, MongoDB only consider two documents equal if they have the same set of key/value pairs, in the same order.

The elemMatch method is a much better alternative for complex object values.

Parameters

value - the value

Parameters

Return
the filter

Mongodb
.driver.manual reference/operator/query/eq/#op._S_eq