contains

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

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.

Return

the filter

Parameters

value

the value

the value type