Skip to content

DeleteOperations

The different MongoDB operations related to deleting documents.

Inheritors

Properties

context

abstract val context: BsonContext

The full BSON configuration, used by the DSL to generate queries.

For more information, see BsonContext.

factory

abstract val factory: BsonFactory

The BsonFactory used to serialize and deserialize values.

This property stores all serialization configurations and allows creating custom BSON objects.

For more information, see BsonFactory.

objectIdGenerator

The algorithm used to generate new ObjectId instances.

For more information, see ObjectIdGenerator.

propertyNameStrategy

The strategy used to convert property names to BSON document keys.

For more information, see PropertyNameStrategy.

Functions

deleteMany

abstract fun deleteMany(options: DeleteManyOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit)

Deletes all documents that match filter.

Example

class User(
    val name: String,
    val age: Int
)

collection.deleteMany {
    User::age lt 18
}

External resources

deleteOne

abstract fun deleteOne(options: DeleteOneOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit)

Deletes the first document found that matches filter.

Example

class User(
    val name: String,
    val age: Int
)

collection.deleteOne {
    User::name eq "Bob"
}

External resources