kmongo / org.litote.kmongo / com.mongodb.client.MongoCollection / findOne

findOne

fun <T> MongoCollection<T>.findOne(filter: String = KMongoUtil.EMPTY_JSON): T? (source)
fun <T> MongoCollection<T>.findOne(filter: Bson): T? (source)

Finds the first document that match the filter in the collection.

Parameters

filter - the query filter

Return
the first item returned or null

fun <T> MongoCollection<T>.findOne(vararg filters: Bson?): T? (source)

Finds the first document that match the filters in the collection.

Parameters

filters - the query filters

Return
the first item returned or null

inline fun <reified T : Any> MongoCollection<T>.findOne(filters: () -> Bson): T? (source)

Finds the first document that match the filter in the collection.

Parameters

filters - the query filters

Return
the first item returned or null

fun <T> MongoCollection<T>.findOne(clientSession: ClientSession, filter: String = KMongoUtil.EMPTY_JSON): T? (source)
fun <T> MongoCollection<T>.findOne(clientSession: ClientSession, filter: Bson): T? (source)

Finds the first document that match the filter in the collection.

Parameters

clientSession - the client session with which to associate this operation

filter - the query filter

Return
the first item returned or null

fun <T> MongoCollection<T>.findOne(clientSession: ClientSession, vararg filters: Bson?): T? (source)

Finds the first document that match the filters in the collection.

Parameters

clientSession - the client session with which to associate this operation

filters - the query filters

Return
the first item returned or null

inline fun <reified T : Any> MongoCollection<T>.findOne(clientSession: ClientSession, filters: () -> Bson): T? (source)

Finds the first document that match the filter in the collection.

Parameters

clientSession - the client session with which to associate this operation

filters - the query filters

Return
the first item returned or null