deleteOne

abstract suspend fun deleteOne(filter: Bson): DeleteResult

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

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Parameters

filter

the query filter to apply the the delete operation

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoException

abstract suspend fun deleteOne(filter: Bson, options: DeleteOptions): DeleteResult

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

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Parameters

filter

the query filter to apply the the delete operation

options

the options to apply to the delete operation

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoException

abstract suspend fun deleteOne(clientSession: ClientSession, filter: Bson): DeleteResult

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

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Since

3.6

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
com.mongodb.MongoWriteConcernException
com.mongodb.MongoException

abstract suspend fun deleteOne(    clientSession: ClientSession,     filter: Bson,     options: DeleteOptions): DeleteResult

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

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Since

3.6

Parameters

clientSession

the client session with which to associate this operation

filter

the query filter to apply the the delete operation

options

the options to apply to the delete operation

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoException