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

countDocuments

fun <T> MongoCollection<T>.countDocuments(filter: String, options: CountOptions = CountOptions()): Long (source)

Counts the number of documents in the collection according to the given options.

Parameters

filter - the query filter

options - the options describing the count

Return
the number of documents in the collection

fun <T> MongoCollection<T>.countDocuments(clientSession: ClientSession, filter: String, options: CountOptions = CountOptions()): Long (source)

Counts the number of documents in the collection according to the given options.

Parameters

clientSession - the client session with which to associate this operation

filter - the query filter

options - the options describing the count

Return
the number of documents in the collection