distinct

inline fun <TResult : Any> MongoCollection<*>.distinct(fieldName: String, filter: String = KMongoUtil.EMPTY_JSON): DistinctIterable<TResult>

Gets the distinct values of the specified field name.

Return

an iterable of distinct values

Parameters

fieldName

the field name

filter

the query filter

the target type of the iterable.

inline fun <T : Any, TResult> MongoCollection<T>.distinct(field: KProperty1<T, TResult>, filter: Bson = EMPTY_BSON): DistinctIterable<TResult>

Gets the distinct values of the specified field.

Return

an iterable of distinct values

Parameters

field

the field

filter

the query filter

the target type of the iterable.

inline fun <TResult : Any> MongoCollection<*>.distinct(clientSession: ClientSession, fieldName: String, filter: String = KMongoUtil.EMPTY_JSON): DistinctIterable<TResult>

Gets the distinct values of the specified field name.

Return

an iterable of distinct values

Parameters

clientSession

the client session with which to associate this operation

fieldName

the field name

filter

the query filter

the target type of the iterable.

inline fun <T : Any, TResult> MongoCollection<T>.distinct(clientSession: ClientSession, field: KProperty1<T, TResult>, filter: Bson = EMPTY_BSON): DistinctIterable<TResult>

Gets the distinct values of the specified field.

Return

an iterable of distinct values

Parameters

clientSession

the client session with which to associate this operation

field

the field

filter

the query filter

the target type of the iterable.

fun <T> MongoIterable<T>.distinct(): List<T>

Returns a list containing only distinct elements from the given collection.

The elements in the resulting list are in the same order as they were in the source collection.