deleteOne

suspend fun <T : Any> MongoCollection<T>.deleteOne(filter: String, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Return

the result of the remove one operation

Parameters

filter

the query filter to apply the the delete operation

Throws

com.mongodb.MongoWriteException

if the write failed due some other failure specific to the delete command

com.mongodb.MongoWriteConcernException

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

com.mongodb.MongoException

if the write failed due some other failure


suspend fun <T : Any> MongoCollection<T>.deleteOne(vararg filters: Bson?, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Return

the result of the remove one operation

Parameters

filters

the query filters to apply the the delete operation

Throws

com.mongodb.MongoWriteException

if the write failed due some other failure specific to the delete command

com.mongodb.MongoWriteConcernException

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

com.mongodb.MongoException

if the write failed due some other failure


suspend fun <T : Any> MongoCollection<T>.deleteOne(clientSession: ClientSession, filter: String, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Return

the result of the remove one operation

Parameters

clientSession

the client session with which to associate this operation

filter

the query filter to apply the the delete operation

Throws

com.mongodb.MongoWriteException

if the write failed due some other failure specific to the delete command

com.mongodb.MongoWriteConcernException

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

com.mongodb.MongoException

if the write failed due some other failure


suspend fun <T : Any> MongoCollection<T>.deleteOne(clientSession: ClientSession, vararg filters: Bson?, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Return

the result of the remove one operation

Parameters

clientSession

the client session with which to associate this operation

filters

the query filters to apply the the delete operation

Throws

com.mongodb.MongoWriteException

if the write failed due some other failure specific to the delete command

com.mongodb.MongoWriteConcernException

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

com.mongodb.MongoException

if the write failed due some other failure