Trait mango_orm::models::db_query_api::common::QCommon[][src]

pub trait QCommon: ToModel + CachingModel {
    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<OutputDataForm, Box<dyn Error>> { ... }
fn delete_one(
        query: Document,
        options: Option<DeleteOptions>
    ) -> Result<OutputDataForm, 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<OutputDataForm, Box<dyn Error>> { ... }
fn estimated_document_count(
        options: Option<EstimatedDocumentCountOptions>
    ) -> Result<i64, Box<dyn Error>> { ... }
fn find(
        filter: Option<Document>,
        options: Option<FindOptions>
    ) -> Result<OutputDataMany, Box<dyn Error>> { ... }
fn find_one(
        filter: Option<Document>,
        options: Option<FindOneOptions>
    ) -> Result<OutputDataOne, Box<dyn Error>> { ... }
fn find_one_and_delete(
        filter: Document,
        options: Option<FindOneAndDeleteOptions>
    ) -> Result<OutputDataOne, Box<dyn Error>> { ... }
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.1.1/mongodb/struct.Collection.html#method.aggregate See the documentation https://docs.mongodb.com/manual/aggregation/ for more information on aggregations.

Example:

let pipeline = doc!{};
let document  = UserProfile::aggregate(pipeline, None)?;
println!("{:?}", document);

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

Example:

let filter = doc!{};
let count  = UserProfile::count_documents(filter, None)?;
println!("{}", count);

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

Example:

let query = doc!{};
let output_data  = UserProfile::delete_many(query, None)?;
if !routput_data.is_valid() {
    println!("{}", routput_data.err_msg());
}

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

Example:

let query = doc!{};
let output_data  = UserProfile::delete_one(query, None)?;
if !routput_data.is_valid() {
    println!("{}", routput_data.err_msg());
}

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

Example:

let ield_name = "";
let filter = doc!{};
let output_data  = UserProfile::distinct(field_name, filter, None)?;
println!("{:?}", routput_data);

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

Example:

let output_data  = UserProfile::drop(None)?;
if !routput_data.is_valid() {
    println!("{}", routput_data.err_msg());
}

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

Example:

let count  = UserProfile::estimated_document_count(None)?;
println!("{}", count);

Finds the documents in the collection matching filter. https://docs.rs/mongodb/1.1.1/mongodb/struct.Collection.html#method.find

Example:

let filter = doc!{};
let output_data  = UserProfile::find(filter, None)?;
if output_data.is_valid()? {
    // Get raw documents. (Hint: For non-standard operations.)
    println!("{:?}", routput_data.raw_docs()?);
    // Get prepared documents. (Hint: For page template.)
    println!("{:?}", routput_data.docs()?);
    // Get json-line. (Hint: For Ajax.)
    println!("{:?}", routput_data.json()?);
    // Get the number of documents.
    println!("{}", routput_data.count()?);
}

Finds a single document in the collection matching filter. https://docs.rs/mongodb/1.1.1/mongodb/struct.Collection.html#method.find_one

Example:

let filter = doc!{};
let output_data  = UserProfile::find_one(filter, None)?;
if output_data.is_valid()? {
    // Get raw document. (Hint: For non-standard operations.)
    println!("{:?}", output_data.raw_doc()?);
    // Get prepared document. (Hint: For page template.)
    println!("{:?}", output_data.doc()?);
    //Get json-line. (Hint: For Ajax.)
    println!("{}", output_data.json()?);
    // Get model instance. (Hint: For the `save`, `update`, `delete` operations.)
    println!("{:?}", output_data.model::<UserProfile>()?);
}

Atomically finds up to one document in the collection matching filter and deletes it. https://docs.rs/mongodb/1.1.1/mongodb/struct.Collection.html#method.find_one_and_delete

Example:

let filter = doc!{};
let output_data  = UserProfile::find_one_and_delete(filter, None)?;
if !routput_data.is_valid() {
    println!("{}", routput_data.err_msg());
}

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

Example:

let name  = UserProfile::name()?;
println!("{}", name);

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

Example:

let name  = UserProfile::namespace()?;
println!("{:?}", name);

Implementors