CollectionT

Trait CollectionT 

Source
pub trait CollectionT<T> {
Show 16 methods // Required methods fn name(&self) -> &str; fn count_documents(&self) -> Result<u64>; fn update_one( &self, query: Document, update: Document, ) -> Result<UpdateResult>; fn update_one_with_options( &self, query: Document, update: Document, options: UpdateOptions, ) -> Result<UpdateResult>; fn update_many( &self, query: Document, update: Document, ) -> Result<UpdateResult>; fn update_many_with_options( &self, query: Document, update: Document, options: UpdateOptions, ) -> Result<UpdateResult>; fn delete_one(&self, query: Document) -> Result<DeleteResult>; fn delete_many(&self, query: Document) -> Result<DeleteResult>; fn create_index(&self, index: IndexModel) -> Result<()>; fn drop_index(&self, name: impl AsRef<str>) -> Result<()>; fn drop(&self) -> Result<()>; fn insert_one(&self, doc: impl Borrow<T>) -> Result<InsertOneResult> where T: Serialize; fn insert_many( &self, docs: impl IntoIterator<Item = impl Borrow<T>>, ) -> Result<InsertManyResult> where T: Serialize; fn find(&self, filter: Document) -> Find<'_, '_, T> where T: DeserializeOwned + Send + Sync; fn find_one(&self, filter: Document) -> Result<Option<T>> where T: DeserializeOwned + Send + Sync; fn aggregate( &self, pipeline: impl IntoIterator<Item = Document>, ) -> Aggregate<'_, '_>;
}

Required Methods§

Source

fn name(&self) -> &str

Source

fn count_documents(&self) -> Result<u64>

Return the size of all data in the collection.

Source

fn update_one(&self, query: Document, update: Document) -> Result<UpdateResult>

Updates up to one document matching query in the collection. documentation for more information on specifying updates.

Source

fn update_one_with_options( &self, query: Document, update: Document, options: UpdateOptions, ) -> Result<UpdateResult>

Source

fn update_many(&self, query: Document, update: Document) -> Result<UpdateResult>

Updates all documents matching query in the collection. documentation for more information on specifying updates.

Source

fn update_many_with_options( &self, query: Document, update: Document, options: UpdateOptions, ) -> Result<UpdateResult>

Source

fn delete_one(&self, query: Document) -> Result<DeleteResult>

Deletes up to one document found matching query.

Source

fn delete_many(&self, query: Document) -> Result<DeleteResult>

When query is None, all the data in the collection will be deleted.

The size of data deleted returns.

Source

fn create_index(&self, index: IndexModel) -> Result<()>

Source

fn drop_index(&self, name: impl AsRef<str>) -> Result<()>

Drops the index specified by name from this collection.

Source

fn drop(&self) -> Result<()>

Source

fn insert_one(&self, doc: impl Borrow<T>) -> Result<InsertOneResult>
where T: Serialize,

Inserts doc into the collection.

Source

fn insert_many( &self, docs: impl IntoIterator<Item = impl Borrow<T>>, ) -> Result<InsertManyResult>
where T: Serialize,

Inserts the data in docs into the collection.

Source

fn find(&self, filter: Document) -> Find<'_, '_, T>
where T: DeserializeOwned + Send + Sync,

When query document is passed to the function. The result satisfies the query document.

Source

fn find_one(&self, filter: Document) -> Result<Option<T>>
where T: DeserializeOwned + Send + Sync,

Finds a single document in the collection matching filter.

Source

fn aggregate( &self, pipeline: impl IntoIterator<Item = Document>, ) -> Aggregate<'_, '_>

Runs an aggregation operation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§