replaceOne
fun replaceOne(options: ReplaceOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit = {}, document: Document)(source)
Replaces a document that matches filter by document.
If multiple documents match filter, only the first one found is updated.
Example
class User(
val name: String,
val age: Int,
)
collection.bulkWrite {
replaceOne(
filter = { User::name eq "Patrick" },
document = User("Bob", 15)
)
}
Content copied to clipboard
External resources
See also
Update an existing document.
Replace a document, or insert it if it doesn't exist.