deleteMany

suspend fun deleteMany(filter: Bson, options: DeleteOptions = DeleteOptions()): DeleteResult

Removes all documents from the collection that match the given query filter.

If no documents match, the collection is not modified.

Return

the result of the remove many operation

Parameters

filter

the query filter to apply the delete operation

options

the options to apply to the delete operation

Throws

MongoWriteException

if the write failed due to some specific write exception

MongoWriteConcernException

if the write failed due to being unable to fulfil the write concern

MongoCommandException

if the write failed due to a specific command exception

MongoException

if the write failed due some other failure


suspend fun deleteMany(clientSession: ClientSession, filter: Bson, options: DeleteOptions = DeleteOptions()): DeleteResult

Removes all documents from the collection that match the given query filter.

If no documents match, the collection is not modified.

Return

the result of the remove many operation

Parameters

clientSession

the client session with which to associate this operation

filter

the query filter to apply the delete operation

options

the options to apply to the delete operation

Throws

MongoWriteException

if the write failed due to some specific write exception

MongoWriteConcernException

if the write failed due to being unable to fulfil the write concern

MongoCommandException

if the write failed due to a specific command exception

MongoException

if the write failed due some other failure