countDocuments

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

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

Return

the number of documents in the collection

Parameters

filter

the query filter

options

the options describing the count


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

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

Return

the number of documents in the collection

Parameters

clientSession

the client session with which to associate this operation

filter

the query filter

options

the options describing the count