pub trait QPaladins: Main + Caching + Hooks + Validation + AdditionalValidation {
    fn delete_file(
        &self,
        coll: &Collection,
        model_name: &str,
        field_name: &str,
        file_default: Option<FileData>,
        image_default: Option<ImageData>
    ) -> Result<(), Box<dyn Error>> { ... } fn db_get_file_info(
        &self,
        coll: &Collection,
        field_name: &str
    ) -> Result<Value, Box<dyn Error>> { ... } fn calculate_thumbnail_size(
        width: f64,
        height: f64,
        max_size: f64
    ) -> (f64, f64) { ... } fn check(
        &mut self,
        is_save: Option<bool>
    ) -> Result<OutputData2, Box<dyn Error>>
    where
        Self: Serialize + DeserializeOwned + Sized
, { ... } fn save(
        &mut self,
        options_insert: Option<InsertOneOptions>,
        options_update: Option<UpdateOptions>
    ) -> Result<OutputData2, Box<dyn Error>>
    where
        Self: Serialize + DeserializeOwned + Sized
, { ... } fn delete(
        &self,
        options: Option<DeleteOptions>
    ) -> Result<OutputData, Box<dyn Error>>
    where
        Self: Serialize + DeserializeOwned + Sized
, { ... } fn create_password_hash(field_value: &str) -> Result<String, Box<dyn Error>> { ... } fn verify_password(
        &self,
        password: &str,
        options: Option<FindOneOptions>
    ) -> Result<bool, Box<dyn Error>>
    where
        Self: Serialize + DeserializeOwned + Sized
, { ... } fn update_password(
        &self,
        old_password: &str,
        new_password: &str,
        options_find_old: Option<FindOneOptions>,
        options_update: Option<UpdateOptions>
    ) -> Result<OutputData, Box<dyn Error>>
    where
        Self: Serialize + DeserializeOwned + Sized
, { ... } }

Provided Methods

Deleting a file in the database and in the file system.

Get file info from database.

Calculate the maximum size for a thumbnail.

Checking the Model before queries the database.

Example:
let mut model_name = ModelName::new()?;
let output_data = model_name.check(None)?;
if !output_data.is_valid() {
    output_data.print_err();
}

Save to database as a new document or update an existing document. Hint: Used in conjunction with the check() method.

Example:
let mut model_name = ModelName::new()?;
let output_data = model_name.save(None, None)?;
if !output_data.is_valid() {
    output_data.print_err();
}

Remove document from collection.

Example:
let mut user = User{...};
let output_data = user.delete(None)?;
if !output_data.is_valid() {
    println!("{}", output_data.err_msg());
}

Generate password hash and add to result document.

Example:
let user = User {...};
let field_value = user.password;
println!("{}", user.create_password_hash(field_value)?);

Match the password from the user to the password in the database.

Example:
let user = User {...};
let password = "12345678";
assert!(user.create_password_hash(password, None)?);

For replace or recover password.

Example:
let user = User {...};
let old_password = "12345678";
// Valid characters: a-z A-Z 0-9 @ # $ % ^ & + = * ! ~ ) (
// Size: 8-256
let new_password = "UUbd+5KXw^756*uj";
let output_data = user.update_password(old_password, new_password, None)?;
if !output_data.is_valid()? {
    println!("{}", output_data.err_msg()?);
}

Implementors