MongoCollection.findOne

deprecated("Use the overload taking `FindOptions` instead, this method breaks in MongoDB 5.1 and onwards. Note: using a `$query` / `query` member to override the query arguments is no longer supported in the new overload.") auto findOne(R = Bson, T, U)(T query, U returnFieldSelector, QueryFlags flags)
No documentation available for this declaration.
auto findOne(R = Bson, T, U)(T query, U projection, FindOptions options = FindOptions.init) if (!is(U == FindOptions))

Queries the collection for existing documents.

Returns

By default, a Bson value of the matching document is returned, or Bson(null)

when no document matched. For types R that are not Bson, the returned value is either of type R, or of type , if R is not a reference/pointer type.

The projection parameter limits what fields are returned by the database, see projection documentation linked below.

Throws

Exception if a DB communication error or a query error occurred.

See Also

auto findOne(R = Bson, T)(T query, FindOptions options = FindOptions.init)

Queries the collection for existing documents.

Returns

By default, a Bson value of the matching document is returned, or Bson(null)

when no document matched. For types R that are not Bson, the returned value is either of type R, or of type , if R is not a reference/pointer type.

Throws

Exception if a DB communication error or a query error occurred.

See Also