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§
fn name(&self) -> &str
Sourcefn count_documents(&self) -> Result<u64>
fn count_documents(&self) -> Result<u64>
Return the size of all data in the collection.
Sourcefn update_one(&self, query: Document, update: Document) -> Result<UpdateResult>
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.
fn update_one_with_options( &self, query: Document, update: Document, options: UpdateOptions, ) -> Result<UpdateResult>
Sourcefn update_many(&self, query: Document, update: Document) -> Result<UpdateResult>
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.
fn update_many_with_options( &self, query: Document, update: Document, options: UpdateOptions, ) -> Result<UpdateResult>
Sourcefn delete_one(&self, query: Document) -> Result<DeleteResult>
fn delete_one(&self, query: Document) -> Result<DeleteResult>
Deletes up to one document found matching query.
Sourcefn delete_many(&self, query: Document) -> Result<DeleteResult>
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.
fn create_index(&self, index: IndexModel) -> Result<()>
Sourcefn drop_index(&self, name: impl AsRef<str>) -> Result<()>
fn drop_index(&self, name: impl AsRef<str>) -> Result<()>
Drops the index specified by name from this collection.
fn drop(&self) -> Result<()>
Sourcefn insert_one(&self, doc: impl Borrow<T>) -> Result<InsertOneResult>where
T: Serialize,
fn insert_one(&self, doc: impl Borrow<T>) -> Result<InsertOneResult>where
T: Serialize,
Inserts doc into the collection.
Sourcefn insert_many(
&self,
docs: impl IntoIterator<Item = impl Borrow<T>>,
) -> Result<InsertManyResult>where
T: Serialize,
fn insert_many(
&self,
docs: impl IntoIterator<Item = impl Borrow<T>>,
) -> Result<InsertManyResult>where
T: Serialize,
Inserts the data in docs into the collection.
Sourcefn find(&self, filter: Document) -> Find<'_, '_, T>
fn find(&self, filter: Document) -> Find<'_, '_, T>
When query document is passed to the function. The result satisfies the query document.
Sourcefn find_one(&self, filter: Document) -> Result<Option<T>>
fn find_one(&self, filter: Document) -> Result<Option<T>>
Finds a single document in the collection matching filter.
Sourcefn aggregate(
&self,
pipeline: impl IntoIterator<Item = Document>,
) -> Aggregate<'_, '_>
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.