pub struct Collection<T: Doc> { /* fields omitted */ }
A statically-typed (homogeneous) MongoDB
collection.
Creates indexes on the underlying MongoDB
collection
according to the given index specifications.
Returns the number of documents matching the query criteria.
Returns the distinct values of a certain field.
Runs an aggregation pipeline.
Retrieves a single document satisfying the query, if one exists.
Retrieves all documents satisfying the query.
Inserts a single document.
Convenience method for updating a single document based on identity (its
_id
field), setting all fields to the values supplied by entity
.
This doesn't add a new document if none with the specified _id
exists.
Convenience method for updating a single document based on identity (its
_id
field), setting all fields to the values supplied by entity
.
This method adds a new document if none with the specified _id
exists.
Updates a single document.
This method only works with update operators (with field names starting
with $
), i.e. it does not replace entire documents.
Upserts a single document.
This method only works with update operators (with field names starting
with $
), i.e. it does not replace entire documents.
Updates multiple documents.
This method only works with update operators (with field names starting
with $
), i.e. it does not replace entire documents.
Upserts multiple documents (updates many or inserts one if none found).
This method only works with update operators (with field names starting
with $
), i.e. it does not replace entire documents.
Convenience method for deleting a single entity based on its identity
(the _id
field). Returns true
if it was found and deleted.
Convenience method for deleting entities based on their identity
(the _id
fields). Returns the number of deleted documents.
Deletes one document. Returns true
if one was found and deleted.
Deletes many documents. Returns the number of deleted documents.
Deletes a single document based on the query criteria,
returning it if it was found.
Replaces a single document based on the query criteria.
Returns the original document if found.
This method does not provide an option for returning the updated
document, since it already requires the presence of a replacement.
Finds a single document based on query criteria and updates it.
For convenience reasons, unlike others, this API is NOT split into
separate update and upsert functions. The options returned by the
update
argument decide whether an update or an upsert happens.
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T, U> TryInto for T where U: TryFrom<T>, | |
type Err = <U as TryFrom<T>>::Err