pub trait QCommons: Main + Caching + Converters {
Show 19 methods // Provided methods fn create_index<'life0, 'async_trait>( client: &'life0 Client, index: IndexModel, options: impl 'async_trait + Into<Option<CreateIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<CreateIndexResult, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn drop_index<'life0, 'async_trait>( client: &'life0 Client, name: impl 'async_trait + AsRef<str>, options: impl 'async_trait + Into<Option<DropIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn create_indexes<'life0, 'async_trait>( client: &'life0 Client, indexes: impl 'async_trait + IntoIterator<Item = IndexModel>, options: impl 'async_trait + Into<Option<CreateIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<CreateIndexesResult, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn drop_indexes<'life0, 'async_trait>( client: &'life0 Client, options: impl 'async_trait + Into<Option<DropIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn aggregate<'life0, 'async_trait>( client: &'life0 Client, pipeline: Vec<Document>, options: Option<AggregateOptions> ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn count_documents<'life0, 'async_trait>( client: &'life0 Client, filter: Option<Document>, options: Option<CountOptions> ) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn delete_many<'life0, 'async_trait>( client: &'life0 Client, query: Document, options: Option<DeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn delete_one<'life0, 'async_trait>( client: &'life0 Client, query: Document, options: Option<DeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn distinct<'life0, 'life1, 'async_trait>( client: &'life0 Client, field_name: &'life1 str, filter: Option<Document>, options: Option<DistinctOptions> ) -> Pin<Box<dyn Future<Output = Result<Vec<Bson>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn drop<'life0, 'async_trait>( client: &'life0 Client, options: Option<DropCollectionOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn estimated_document_count<'life0, 'async_trait>( client: &'life0 Client, options: Option<EstimatedDocumentCountOptions> ) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn find_many_to_doc_list<'life0, 'async_trait>( client: &'life0 Client, filter: Option<Document>, options: Option<FindOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Document>>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn find_many_to_json<'life0, 'async_trait>( client: &'life0 Client, filter: Option<Document>, options: Option<FindOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn find_one_to_doc<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn find_one_to_json<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn find_one_to_instance<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn find_one_and_delete<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneAndDeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn collection_name<'life0, 'async_trait>( client: &'life0 Client ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... } fn namespace<'life0, 'async_trait>( client: &'life0 Client ) -> Pin<Box<dyn Future<Output = Result<Namespace, Box<dyn Error>>> + 'async_trait>> where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

Common query methods.

Provided Methods§

source

fn create_index<'life0, 'async_trait>( client: &'life0 Client, index: IndexModel, options: impl 'async_trait + Into<Option<CreateIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<CreateIndexResult, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Creates the given index on this collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.create_index

Example:
let options = IndexOptions::builder()
    .unique(true)
    .name("usernameIdx".to_string())
    .build();
let index = IndexModel::builder()
    .keys(doc! { "username": 1 })
    .options(options)
    .build();
let result = ModelName::create_index(&client, index, None).await;
assert!(result.is_ok());
source

fn drop_index<'life0, 'async_trait>( client: &'life0 Client, name: impl 'async_trait + AsRef<str>, options: impl 'async_trait + Into<Option<DropIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Creates the given index on this collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.create_index

Example:
let name = "usernameIdx";
let result = ModelName::drop_index(&client, name, None).await;
assert!(result.is_ok());
source

fn create_indexes<'life0, 'async_trait>( client: &'life0 Client, indexes: impl 'async_trait + IntoIterator<Item = IndexModel>, options: impl 'async_trait + Into<Option<CreateIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<CreateIndexesResult, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Creates the given indexes on this collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.create_indexes

Example:
let username_idx_options = IndexOptions::builder()
    .unique(true)
    .name("usernameIdx".to_string())
    .build();
let indexes = [IndexModel::builder()
    .keys(doc! { "username": 1 })
    .options(username_idx_options)
    .build()];
let result = ModelName::create_indexes(&client, indexes, None).await;
assert!(result.is_ok());
source

fn drop_indexes<'life0, 'async_trait>( client: &'life0 Client, options: impl 'async_trait + Into<Option<DropIndexOptions>> ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Drops all indexes associated with this collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.drop_indexes

Example:
let result = ModelName::drop_indexes(&client, None).await;
assert!(result.is_ok());
source

fn aggregate<'life0, 'async_trait>( client: &'life0 Client, pipeline: Vec<Document>, options: Option<AggregateOptions> ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Runs an aggregation operation. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.aggregate

Example:
use mongodb::bson::doc;

let pipeline = vec![doc! {}];
let doc_list  = ModelName::aggregate(&client, pipeline, None).await?;
println!("{:?}", doc_list);
source

fn count_documents<'life0, 'async_trait>( client: &'life0 Client, filter: Option<Document>, options: Option<CountOptions> ) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Gets the number of documents matching filter. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.count_documents

Example:
use mongodb::bson::doc;

let filter = doc!{};
let count  = ModelName::count_documents &client, Some(filter), None).await?;
println!("{}", count);
source

fn delete_many<'life0, 'async_trait>( client: &'life0 Client, query: Document, options: Option<DeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Deletes all documents stored in the collection matching query. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.delete_many

Example:
use mongodb::bson::doc;

let query = doc!{};
let output_data  = ModelName::delete_many(&client, query, None).await?;
if !output_data.is_valid() {
    println!("{}", output_data.err_msg());
}
source

fn delete_one<'life0, 'async_trait>( client: &'life0 Client, query: Document, options: Option<DeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Deletes up to one document found matching query. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.delete_one

Example:
use mongodb::bson::doc;

let query = doc!{};
let output_data  = ModelName::delete_one(&client, query, None).await?;
if !output_data.is_valid() {
    println!("{}", output_data.err_msg());
}
source

fn distinct<'life0, 'life1, 'async_trait>( client: &'life0 Client, field_name: &'life1 str, filter: Option<Document>, options: Option<DistinctOptions> ) -> Pin<Box<dyn Future<Output = Result<Vec<Bson>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Finds the distinct values of the field specified by field_name across the collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.distinct

Example:
use mongodb::bson::doc;

let field_name = "";
let filter = doc!{};
let output_data  = ModelName::distinct(&client, field_name, Some(filter), None).await?;
println!("{:?}", output_data);
source

fn drop<'life0, 'async_trait>( client: &'life0 Client, options: Option<DropCollectionOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Drops the collection, deleting all data and indexes stored in it. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.drop

Example:
let output_data  = ModelName::drop &client, None).await?;
if !output_data.is_valid() {
    println!("{}", output_data.err_msg());
}
source

fn estimated_document_count<'life0, 'async_trait>( client: &'life0 Client, options: Option<EstimatedDocumentCountOptions> ) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Estimates the number of documents in the collection using collection metadata. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.estimated_document_count

Example:
let count  = ModelName::estimated_document_count &client, None).await?;
println!("{}", count);
source

fn find_many_to_doc_list<'life0, 'async_trait>( client: &'life0 Client, filter: Option<Document>, options: Option<FindOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Document>>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Finds the documents in the collection matching filter and return document list ( missing fields type ). https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.find

Example:
let result = ModelName::find_many_to_doc_list &client, None, None).await?;
if let Some(doc_list) = result {
    println!("{:?}", doc_list);
}
source

fn find_many_to_json<'life0, 'async_trait>( client: &'life0 Client, filter: Option<Document>, options: Option<FindOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Finds the documents in the collection matching filter and return in JSON format ( missing fields type ). https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.find

Example:
let result = ModelName::find_many_to_json &client, None, None).await?;
if let Some(json_line) = result {
    println!("{}", json_line);
}
source

fn find_one_to_doc<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Finds a single document in the collection matching filter and return in Doc format ( missing fields type ). https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.find_one

Example:
use mongodb::bson::doc;
let filter = doc!{"username": "user_1"};
let result = ModelName::find_one_to_doc(&client, filter, None).await?;
if let Some(doc) = result {
    println!("{:?}", doc);
}
source

fn find_one_to_json<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Finds a single document in the collection matching filter and return in JSON format. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.find_one

Example:
use mongodb::bson::doc;
let filter = doc!{"username": "user_1"};
let json = ModelName::find_one_to_json(&client, filter, None).await?;
println!("{}", json);
source

fn find_one_to_instance<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Finds a single document in the collection matching filter and return as model instance. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.find_one

Example:
use mongodb::bson::doc;
let filter = doc!{"username": "user_1"};
let result  = ModelName::find_one_to_instance(&client, filter, None).await?;
if let Some(instance) = result {
    println!("{:?}", instance);
}
source

fn find_one_and_delete<'life0, 'async_trait>( client: &'life0 Client, filter: Document, options: Option<FindOneAndDeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<Option<Document>, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Atomically finds up to one document in the collection matching filter and deletes it ( missing fields type ). Returns the deleted document (in Doc format). https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.find_one_and_delete

Example:

use mongodb::bson::doc; let filter = doc!{“username”: “user_1”}; let result = ModelName::find_one_and_delete(&client, filter, None).await?; if let Some(doc) = result) { println!(“{:?}”, doc); }

source

fn collection_name<'life0, 'async_trait>( client: &'life0 Client ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Gets the name of the Collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.name

Example:
let name  = ModelName::name &client).await?;
println!("{}", name);
source

fn namespace<'life0, 'async_trait>( client: &'life0 Client ) -> Pin<Box<dyn Future<Output = Result<Namespace, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait,

Gets the namespace of the Collection. https://docs.rs/mongodb/latest/mongodb/struct.Collection.html#method.namespace

Example:
let name  = ModelName::namespace &client).await?;
println!("{:?}", name);

Implementors§