kmongo / org.litote.kmongo.coroutine / CoroutineCollection / countDocuments

countDocuments

suspend fun countDocuments(filter: Bson = EMPTY_BSON, options: CountOptions = CountOptions()): Long (source)

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

Note: When migrating from count() to countDocuments() the following query operators must be replaced:

Parameters

filter - the query filter

options - the options describing the count

Since
1.9

suspend fun countDocuments(clientSession: ClientSession, filter: Bson = EMPTY_BSON, options: CountOptions = CountOptions()): Long (source)

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

Note: When migrating from count() to countDocuments() the following query operators must be replaced:

Parameters

clientSession - the client session with which to associate this operation

filter - the query filter

options - the options describing the count

Mongodb
.server.release 3.6

Since
1.9

suspend fun 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

Return
count of filtered collection

suspend fun 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 - optional parameter, the options describing the count * @return count of filtered collection