Trait green_barrel::models::converters::Converters
source · pub trait Converters {
// Provided methods
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<'async_trait>(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection<Document>
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error>>> + 'async_trait>> { ... }
fn many_to_json<'life0, 'life1, 'life2, 'async_trait>(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection<Document>,
ignore_fields: &'life0 [String],
field_type_map: &'life1 HashMap<String, String>,
model_name: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Box<dyn Error>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}
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<'async_trait>(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection<Document>
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error>>> + 'async_trait>>
fn many_to_doc_list<'async_trait>( filter: Option<Document>, find_options: Option<FindOptions>, collection: Collection<Document> ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, Box<dyn Error>>> + 'async_trait>>
Get prepared documents ( missing fields type ).
sourcefn many_to_json<'life0, 'life1, 'life2, 'async_trait>(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection<Document>,
ignore_fields: &'life0 [String],
field_type_map: &'life1 HashMap<String, String>,
model_name: &'life2 str
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Box<dyn Error>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn many_to_json<'life0, 'life1, 'life2, 'async_trait>( filter: Option<Document>, find_options: Option<FindOptions>, collection: Collection<Document>, ignore_fields: &'life0 [String], field_type_map: &'life1 HashMap<String, String>, model_name: &'life2 str ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Box<dyn Error>>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Get json-line from document list ( missing fields type ).