[−][src]Struct avocado::coll::Collection
A statically-typed (homogeneous) MongoDB
collection.
Methods
impl<T: Doc> Collection<T>
[src]
impl<T: Doc> Collection<T>
pub fn create_indexes(&self) -> Result<()>
[src]
pub fn create_indexes(&self) -> Result<()>
Creates indexes on the underlying MongoDB
collection
according to the given index specifications.
pub fn drop(&self) -> Result<()>
[src]
pub fn drop(&self) -> Result<()>
Deletes the collection.
pub fn count<Q: Count<T>>(&self, query: Q) -> Result<usize>
[src]
pub fn count<Q: Count<T>>(&self, query: Q) -> Result<usize>
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]
pub fn distinct<Q, C>(&self, query: Q) -> Result<C> where
Q: Distinct<T>,
C: FromIterator<Q::Output>,
Returns the distinct values of a certain field.
pub fn aggregate<P: Pipeline<T>>(
&self,
pipeline: P
) -> Result<Cursor<P::Output>>
[src]
pub fn aggregate<P: Pipeline<T>>(
&self,
pipeline: P
) -> Result<Cursor<P::Output>>
Runs an aggregation pipeline.
pub fn find_one<Q: Query<T>>(&self, query: Q) -> Result<Option<Q::Output>>
[src]
pub fn find_one<Q: Query<T>>(&self, query: Q) -> Result<Option<Q::Output>>
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]
pub fn find_many<Q: Query<T>>(&self, query: Q) -> Result<Cursor<Q::Output>>
Retrieves all documents satisfying the query.
pub fn insert_one(&self, entity: &T) -> Result<Uid<T>>
[src]
pub fn insert_one(&self, entity: &T) -> Result<Uid<T>>
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]
pub fn insert_many<I>(&self, entities: I) -> Result<Vec<Uid<T>>> where
I: IntoIterator,
I::Item: Borrow<T>,
I::IntoIter: ExactSizeIterator,
Inserts many documents.
pub fn replace_entity(&self, entity: &T) -> Result<UpdateOneResult> where
T: Debug,
[src]
pub fn replace_entity(&self, entity: &T) -> Result<UpdateOneResult> where
T: Debug,
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]
pub fn upsert_entity(&self, entity: &T) -> Result<UpsertOneResult<Uid<T>>> where
T: Debug,
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]
pub fn update_one<U: Update<T>>(&self, update: U) -> Result<UpdateOneResult>
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]
pub fn upsert_one<U: Upsert<T>>(
&self,
upsert: U
) -> Result<UpsertOneResult<Uid<T>>>
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]
pub fn update_many<U: Update<T>>(&self, update: U) -> Result<UpdateManyResult>
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]
pub fn upsert_many<U: Upsert<T>>(&self, upsert: U) -> Result<UpsertManyResult>
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]
pub fn delete_entity(&self, entity: &T) -> Result<bool> where
T: Debug,
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>,
I::IntoIter: ExactSizeIterator,
[src]
pub fn delete_entities<I>(&self, entities: I) -> Result<usize> where
I: IntoIterator,
I::Item: Borrow<T>,
I::IntoIter: ExactSizeIterator,
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]
pub fn delete_one<Q: Delete<T>>(&self, query: Q) -> Result<bool>
Deletes one document. Returns true
if one was found and deleted.
pub fn delete_many<Q: Delete<T>>(&self, query: Q) -> Result<usize>
[src]
pub fn delete_many<Q: Delete<T>>(&self, query: Q) -> Result<usize>
Deletes many documents. Returns the number of deleted documents.
Trait Implementations
Auto Trait Implementations
impl<T> Send for Collection<T> where
T: Send,
impl<T> Send for Collection<T> where
T: Send,
impl<T> Sync for Collection<T> where
T: Sync,
impl<T> Sync for Collection<T> where
T: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
impl<T, U> TryInto for T where
U: TryFrom<T>,
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self