pub trait Caching: Main + Converters {
fn caching() -> Result<(), Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
fn meta() -> Result<Meta, Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
fn new() -> Result<Self, Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
fn json() -> Result<String, Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
fn model_to_json_for_admin() -> Result<String, Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
fn get_cache_data_for_query(
) -> Result<(ModelCache, Client), Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
fn update_dyn_field(dyn_data: Value) -> Result<(), Box<dyn Error>>
where
Self: Serialize + DeserializeOwned + Sized,
{ ... }
}
Expand description
Caching inmodelation about Models for speed up work.
Provided Methods
sourcefn caching() -> Result<(), Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
fn caching() -> Result<(), Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
Add metadata to cache.
sourcefn new() -> Result<Self, Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
fn new() -> Result<Self, Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
Get a new model instance with custom settings.
Example:
let user = User::new()?;
user.username.set("user");
user.email.set("user_1_@noreply.net");
user.password.set("12345678");
user.confirm_password.set("12345678");
user.is_staff.set(true);
user.is_active.set(true);
println!("{:?}", user);
sourcefn json() -> Result<String, Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
fn json() -> Result<String, Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
Get field attributes in Json modelat for page templates.
Example:
let json_line = UserProfile::json()?;
println!("{}", json_line);
sourcefn model_to_json_for_admin() -> Result<String, Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
fn model_to_json_for_admin() -> Result<String, Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
Json-line for admin panel. ( converts a field map to a list, in the order of the Model fields )
Example:
let json_line = UserProfile::model_to_json_for_admin()?;
println!("{}", json_line);
sourcefn get_cache_data_for_query() -> Result<(ModelCache, Client), Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
fn get_cache_data_for_query() -> Result<(ModelCache, Client), Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
Get cached Model data.
Example:
let (model_cache, client_cache) = UserProfile::get_cache_data_for_query()?;
println!("{:?}", model_cache);
sourcefn update_dyn_field(dyn_data: Value) -> Result<(), Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
fn update_dyn_field(dyn_data: Value) -> Result<(), Box<dyn Error>>where
Self: Serialize + DeserializeOwned + Sized,
Update data for dynamic fields. Hint: For more convenience, use the admin panel - https://github.com/kebasyaty/actix-greenpanel
Example:
let dyn_data = json!({ “field_name”: “field_name”, “value”: 5, // restrict with field attributes “title”: “Title”, “is_delete”: false }); assert!(ModelName::update_dyn_field(dyn_data).is_ok());