Trait green_barrel::models::converters::Converters
source · [−]pub trait Converters {
fn to_prepared_doc(
doc: Document,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Document, Box<dyn Error>> { ... }
fn one_to_json_val(
db_doc: Document,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str,
fields_name: &Vec<String>,
model_json: &mut Value
) -> Result<(), Box<dyn Error>> { ... }
fn many_to_doc_list(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection
) -> Result<Vec<Document>, Box<dyn Error>> { ... }
fn many_to_json(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Option<String>, Box<dyn Error>> { ... }
}
Expand description
Helper methods for converting output data (use in the commons.rs module).
Provided Methods
sourcefn to_prepared_doc(
doc: Document,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Document, Box<dyn Error>>
fn to_prepared_doc(
doc: Document,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Document, Box<dyn Error>>
Get prepared document ( converting data types to model-friendly formats ).
sourcefn one_to_json_val(
db_doc: Document,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str,
fields_name: &Vec<String>,
model_json: &mut Value
) -> Result<(), Box<dyn Error>>
fn one_to_json_val(
db_doc: Document,
ignore_fields: &[String],
field_type_map: &HashMap<String, String>,
model_name: &str,
fields_name: &Vec<String>,
model_json: &mut Value
) -> Result<(), Box<dyn Error>>
In the model instance, in the format serde_json::Value, Update the field type values from the corresponding document from the database.
sourcefn many_to_doc_list(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection
) -> Result<Vec<Document>, Box<dyn Error>>
fn many_to_doc_list(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection
) -> Result<Vec<Document>, Box<dyn Error>>
Get prepared documents ( missing fields type ).