deleteOneById

suspend fun <T : Any> MongoCollection<T>.deleteOneById(id: Any): DeleteResult

Removes at most one document from the id parameter. If no documents match, the collection is not modified.

Parameters

id

the object id

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>.deleteOneById(clientSession: ClientSession, id: Any): DeleteResult

Removes at most one document from the id parameter. If no documents match, the collection is not modified.

Parameters

clientSession

the client session with which to associate this operation

id

the object id

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