[][src]Struct avocado::coll::Collection

pub struct Collection<T: Doc> { /* fields omitted */ }

A statically-typed (homogeneous) MongoDB collection.

Methods

impl<T: Doc> Collection<T>
[src]

pub fn create_indexes(&self) -> Result<()>
[src]

Creates indexes on the underlying MongoDB collection according to the given index specifications.

pub fn drop(&self) -> Result<()>
[src]

Deletes the collection.

pub fn count<Q: Count<T>>(&self, query: Q) -> Result<usize>
[src]

Returns the number of documents matching the query criteria.

pub fn distinct<Q, C>(&self, query: Q) -> Result<C> where
    Q: Distinct<T>,
    C: FromIterator<Q::Output>, 
[src]

Returns the distinct values of a certain field.

pub fn aggregate<P: Pipeline<T>>(
    &self,
    pipeline: P
) -> Result<Cursor<P::Output>>
[src]

Runs an aggregation pipeline.

pub fn find_one<Q: Query<T>>(&self, query: Q) -> Result<Option<Q::Output>>
[src]

Retrieves a single document satisfying the query, if one exists.

pub fn find_many<Q: Query<T>>(&self, query: Q) -> Result<Cursor<Q::Output>>
[src]

Retrieves all documents satisfying the query.

pub fn insert_one(&self, entity: &T) -> Result<Uid<T>>
[src]

Inserts a single document.

pub fn insert_many<I>(&self, entities: I) -> Result<Vec<Uid<T>>> where
    I: IntoIterator,
    I::Item: Borrow<T>,
    I::IntoIter: ExactSizeIterator
[src]

Inserts many documents.

pub fn replace_entity(&self, entity: &T) -> Result<UpdateOneResult> where
    T: Debug
[src]

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.

pub fn upsert_entity(&self, entity: &T) -> Result<UpsertOneResult<Uid<T>>> where
    T: Debug
[src]

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.

pub fn update_one<U: Update<T>>(&self, update: U) -> Result<UpdateOneResult>
[src]

Updates a single document.

This method only works with update operators (with field names starting with $), i.e. it does not replace entire documents.

pub fn upsert_one<U: Upsert<T>>(
    &self,
    upsert: U
) -> Result<UpsertOneResult<Uid<T>>>
[src]

Upserts a single document.

This method only works with update operators (with field names starting with $), i.e. it does not replace entire documents.

pub fn update_many<U: Update<T>>(&self, update: U) -> Result<UpdateManyResult>
[src]

Updates multiple documents.

This method only works with update operators (with field names starting with $), i.e. it does not replace entire documents.

pub fn upsert_many<U: Upsert<T>>(&self, upsert: U) -> Result<UpsertManyResult>
[src]

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.

pub fn delete_entity(&self, entity: &T) -> Result<bool> where
    T: Debug
[src]

Convenience method for deleting a single entity based on its identity (the _id field). Returns true if it was found and deleted.

pub fn delete_entities<I>(&self, entities: I) -> Result<usize> where
    I: IntoIterator,
    I::Item: Borrow<T>,
    T: Debug
[src]

Convenience method for deleting entities based on their identity (the _id fields). Returns the number of deleted documents.

pub fn delete_one<Q: Delete<T>>(&self, query: Q) -> Result<bool>
[src]

Deletes one document. Returns true if one was found and deleted.

pub fn delete_many<Q: Delete<T>>(&self, query: Q) -> Result<usize>
[src]

Deletes many documents. Returns the number of deleted documents.

pub fn find_one_and_delete<Q: Query<T>>(
    &self,
    query: Q
) -> Result<Option<Q::Output>>
[src]

Deletes a single document based on the query criteria, returning it if it was found.

pub fn find_one_and_replace<Q: Query<T>>(
    &self,
    query: Q,
    replacement: &T
) -> Result<Option<Q::Output>> where
    T: Debug
[src]

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.

pub fn find_one_and_update<U: FindAndUpdate<T>>(
    &self,
    update: U
) -> Result<Option<U::Output>>
[src]

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.

Trait Implementations

impl<T: Doc> Debug for Collection<T>
[src]

Auto Trait Implementations

impl<T> Send for Collection<T> where
    T: Send

impl<T> Sync for Collection<T> where
    T: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<T> Same for T

type Output = T

Should always be Self