findOne

inline suspend fun <T> MongoCollection<T>.findOne(filter: BsonDocument? = null, projection: BsonDocument? = null, sort: BsonDocument? = null): T?

Retrieve a single object from the remote collection.

Return

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

Parameters

filter

a filter to select specific documents. If null then no filtering will be done.

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.

Throws

if the underlying App Service HTTP requests fails.

SerializationException

if App Service response could not be deserialized to T.