pub trait QCommons: Main + Caching + Converters {
Show 18 methods
fn aggregate(
pipeline: Vec<Document>,
options: Option<AggregateOptions>
) -> Result<Vec<Document>, Box<dyn Error>> { ... }
fn count_documents(
filter: Option<Document>,
options: Option<CountOptions>
) -> Result<i64, Box<dyn Error>> { ... }
fn delete_many(
query: Document,
options: Option<DeleteOptions>
) -> Result<OutputData, Box<dyn Error>> { ... }
fn delete_one(
query: Document,
options: Option<DeleteOptions>
) -> Result<OutputData, Box<dyn Error>> { ... }
fn distinct(
field_name: &str,
filter: Option<Document>,
options: Option<DistinctOptions>
) -> Result<Vec<Bson>, Box<dyn Error>> { ... }
fn drop(
options: Option<DropCollectionOptions>
) -> Result<OutputData, Box<dyn Error>> { ... }
fn estimated_document_count(
options: Option<EstimatedDocumentCountOptions>
) -> Result<i64, Box<dyn Error>> { ... }
fn find_many_to_doc(
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Option<Vec<Document>>, Box<dyn Error>> { ... }
fn find_many_to_json(
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<String, Box<dyn Error>> { ... }
fn find_one_to_doc(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<Document>, Box<dyn Error>> { ... }
fn find_one_to_json(
filter: Document,
options: Option<FindOneOptions>
) -> Result<String, Box<dyn Error>> { ... }
fn find_one_to_wig(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<HashMap<String, Widget>>, Box<dyn Error>> { ... }
fn find_one_to_model_instance(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<Self>, Box<dyn Error>>
where
Self: DeserializeOwned + Sized,
{ ... }
fn find_one_and_delete_to_doc(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Document>, Box<dyn Error>> { ... }
fn find_one_and_delete_to_json(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<String, Box<dyn Error>> { ... }
fn find_one_and_delete_to_model_instance(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Self>, Box<dyn Error>>
where
Self: DeserializeOwned + Sized,
{ ... }
fn name() -> Result<String, Box<dyn Error>> { ... }
fn namespace() -> Result<Namespace, Box<dyn Error>> { ... }
}
Provided Methods
Runs an aggregation operation. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.aggregate See the documentation https://docs.mongodb.com/manual/aggregation/ for more information on aggregations.
Example:
use mongodb::bson::doc;
let pipeline = vec![doc! {}];
let documents = ModelName::aggregate(pipeline, None)?;
println!("{:?}", documents);
fn count_documents(
filter: Option<Document>,
options: Option<CountOptions>
) -> Result<i64, Box<dyn Error>>
fn count_documents(
filter: Option<Document>,
options: Option<CountOptions>
) -> Result<i64, Box<dyn Error>>
Gets the number of documents matching filter. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.count_documents
Example:
use mongodb::bson::doc;
let filter = doc!{};
let count = ModelName::count_documents(Some(filter), None)?;
println!("{}", count);
fn delete_many(
query: Document,
options: Option<DeleteOptions>
) -> Result<OutputData, Box<dyn Error>>
fn delete_many(
query: Document,
options: Option<DeleteOptions>
) -> Result<OutputData, Box<dyn Error>>
Deletes all documents stored in the collection matching query. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.delete_many
Example:
use mongodb::bson::doc;
let query = doc!{};
let output_data = ModelName::delete_many(query, None)?;
if !output_data.is_valid() {
println!("{}", output_data.err_msg());
}
fn delete_one(
query: Document,
options: Option<DeleteOptions>
) -> Result<OutputData, Box<dyn Error>>
fn delete_one(
query: Document,
options: Option<DeleteOptions>
) -> Result<OutputData, Box<dyn Error>>
Deletes up to one document found matching query. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.delete_one
Example:
use mongodb::bson::doc;
let query = doc!{};
let output_data = ModelName::delete_one(query, None)?;
if !output_data.is_valid() {
println!("{}", output_data.err_msg());
}
Finds the distinct values of the field specified by field_name across the collection. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.distinct
Example:
use mongodb::bson::doc;
let field_name = "";
let filter = doc!{};
let output_data = ModelName::distinct(field_name, Some(filter), None)?;
println!("{:?}", output_data);
fn drop(
options: Option<DropCollectionOptions>
) -> Result<OutputData, Box<dyn Error>>
fn drop(
options: Option<DropCollectionOptions>
) -> Result<OutputData, Box<dyn Error>>
Drops the collection, deleting all data and indexes stored in it. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.drop
Example:
let output_data = ModelName::drop(None)?;
if !output_data.is_valid() {
println!("{}", output_data.err_msg());
}
fn estimated_document_count(
options: Option<EstimatedDocumentCountOptions>
) -> Result<i64, Box<dyn Error>>
fn estimated_document_count(
options: Option<EstimatedDocumentCountOptions>
) -> Result<i64, Box<dyn Error>>
Estimates the number of documents in the collection using collection metadata. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.estimated_document_count
Example:
let count = ModelName::estimated_document_count(None)?;
println!("{}", count);
fn find_many_to_doc(
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Option<Vec<Document>>, Box<dyn Error>>
fn find_many_to_doc(
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<Option<Vec<Document>>, Box<dyn Error>>
Finds the documents in the collection matching filter and return document list ( missing widgets ). https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.find
Example:
let result = ModelName::find_many_to_doc(None, None)?;
if result.is_some() {
println!("{:?}", result.unwrap());
}
fn find_many_to_json(
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<String, Box<dyn Error>>
fn find_many_to_json(
filter: Option<Document>,
options: Option<FindOptions>
) -> Result<String, Box<dyn Error>>
Finds the documents in the collection matching filter and return in JSON format ( missing widgets ). https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.find
Example:
let result = ModelName::find_many_to_json(None, None);
if result.is_ok() {
println!("{}", result?);
}
fn find_one_to_doc(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<Document>, Box<dyn Error>>
fn find_one_to_doc(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<Document>, Box<dyn Error>>
Finds a single document in the collection matching filter and return in Doc format ( missing widgets ). https://docs.rs/mongodb/1.2.5/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(filter, None)?;
if result.is_some() {
println!("{:?}", result.unwrap());
}
fn find_one_to_json(
filter: Document,
options: Option<FindOneOptions>
) -> Result<String, Box<dyn Error>>
fn find_one_to_json(
filter: Document,
options: Option<FindOneOptions>
) -> Result<String, Box<dyn Error>>
Finds a single document in the collection matching filter and return in JSON format ( presence of widgets ). https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.find_one
Example:
use mongodb::bson::doc;
let filter = doc!{"username": "user_1"};
let result = ModelName::find_one_to_json(filter, None);
if result.is_ok() {
println!("{}", result);
}
Finds a single document in the collection matching filter and return widget map. https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.find_one
Example:
use mongodb::bson::doc;
let filter = doc!{"username": "user_1"};
let result = ModelName::find_one_to_wig(filter, None)?;
if result.is_some()) {
println!("{:?}", result.unwrap());
}
fn find_one_to_model_instance(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<Self>, Box<dyn Error>> where
Self: DeserializeOwned + Sized,
fn find_one_to_model_instance(
filter: Document,
options: Option<FindOneOptions>
) -> Result<Option<Self>, Box<dyn Error>> where
Self: DeserializeOwned + Sized,
Finds a single document in the collection matching filter and return as model instance ( missing widgets ). https://docs.rs/mongodb/1.2.5/mongodb/struct.Collection.html#method.find_one
Example:
use mongodb::bson::doc;
let filter = doc!{"username": "user_1"};
let result = ModelName::find_one_to_model_instance(filter, None);
if result.is_ok() {
println!("{:?}", result.unwrap());
}
fn find_one_and_delete_to_doc(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Document>, Box<dyn Error>>
fn find_one_and_delete_to_doc(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Document>, Box<dyn Error>>
Atomically finds up to one document in the collection matching filter and deletes it ( missing widgets ). Returns the deleted document (in Doc format). https://docs.rs/mongodb/1.2.5/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_to_doc(filter, None); if result.is_ok() { println!(“{:?}”, result.unwrap()); }
fn find_one_and_delete_to_json(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<String, Box<dyn Error>>
fn find_one_and_delete_to_json(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<String, Box<dyn Error>>
Atomically finds up to one document in the collection matching filter and deletes it ( missing widgets ). Returns the deleted document (in JSON format). https://docs.rs/mongodb/1.2.5/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_to_json(filter, None); if result.is_ok() { println!(“{}”, result); }
fn find_one_and_delete_to_model_instance(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Self>, Box<dyn Error>> where
Self: DeserializeOwned + Sized,
fn find_one_and_delete_to_model_instance(
filter: Document,
options: Option<FindOneAndDeleteOptions>
) -> Result<Option<Self>, Box<dyn Error>> where
Self: DeserializeOwned + Sized,
Atomically finds up to one document in the collection matching filter and deletes it ( missing widgets ). Returns the deleted document (in Model instance). https://docs.rs/mongodb/1.2.5/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_to_model_instance(filter, None)?; if result.is_some() { println!(“{}”, result.unwrap()); }
Gets the name of the Collection. https://docs.rs/mongodb/1.1.1/mongodb/struct.Collection.html#method.name
Example:
let name = ModelName::name()?;
println!("{}", name);