findOneAndUpdate

inline suspend fun <T> MongoCollection<T>.findOneAndUpdate(filter: BsonDocument, update: BsonDocument, projection: BsonDocument? = null, sort: BsonDocument? = null, upsert: Boolean = false, returnNewDoc: Boolean = false): T?

Find and update or insert a single new object in the remote collection.

Return

the result of the remote findOneAndUpdate invocation deserialized into a T-instance.

Parameters

filter

a filter to select the documents to update.

update

a BsonDocument specifying the updates that should be applied to the documents.

projection

a BsonDocument that describes which fields that are returned from the server. If null then all fields will be returned.

sort

a document describing one or more fields used to sort documents before selecting the single document to return. If null then no sorting will be applied.

upsert

a boolean indicating if a new document should be inserted if the filter does not match any existing documents in the collection.

returnNewDoc

a boolean indicating whether to return the document before or after the update.

Throws

if the underlying App Service HTTP requests fails.

SerializationException

if App Service response could not be deserialized to T.