Trait mango_orm::models::caching::CachingModel[][src]

pub trait CachingModel: ToModel {
    fn to_cache() -> Result<(), Box<dyn Error>> { ... }
fn form_wig() -> Result<HashMap<String, Widget>, Box<dyn Error>> { ... }
fn form_json() -> Result<String, Box<dyn Error>> { ... }
fn form_json_for_admin() -> Result<String, Box<dyn Error>> { ... }
fn form_html() -> Result<String, Box<dyn Error>> { ... }
fn get_cache_data_for_query() -> Result<(FormCache, Client), Box<dyn Error>> { ... }
fn db_update_dyn_widgets(json_line: &str) -> Result<(), Box<dyn Error>> { ... } }
Expand description

Caching information about Models for speed up work.

Provided methods

Add metadata and widgects map to cache.

Get an widgets map for page template.

Example:

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

Get Form attributes in Json format for page templates.

Example:

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

Json-line for admin panel. ( converts a widget map to a list, in the order of the Model fields )

Example:

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

Get Html Form of Model for page templates.

Example:

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

Get cached Model data.

Example:

let (form_cache, client_cache) = UserProfile::get_cache_data_for_query()?;
println!("{:?}", form_cache);

Accepts json-line to update data, for dynamic widgets. Hint: Used in conjunction with the admin panel.

Example:

let json-line =  r#"{"field_name":[["value","Title"]]}"#;
// or
let json-line = r#"{
       "field_name":[["value","Title"]],
       "field_name_2":[["value","Title 2"]],
       "field_name_3":[["value","Title 3"]]
    }"#;

assert!(Dynamic::db_update_dyn_widgets(json-line).is_ok());

Implementors