pub struct OutputData2 {
    pub is_valid: bool,
    pub final_doc: Option<Document>,
    pub final_model_json: Value,
    pub fields_name: Vec<String>,
}
Expand description

Output data for check() and save() methods.

Fields

is_valid: boolfinal_doc: Option<Document>final_model_json: Valuefields_name: Vec<String>

Implementations

Get validation status (boolean).

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

assert!(output_data.is_valid());

If there are AutoSlug fields, do an update. Use only for save() method.

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.save(None, None)?;

if output_data.is_valid() {
    model_name = output_data.update()?;
}

Get/Set Hash-line

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check(None)?;
// or
let output_data = model_name.save(None, None)?;

println!("{}", output_data.hash());
println!("{}", output_data.set_hash(hash_line));

Get MongoDB ID from hash-line

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{:?}", output_data.obj_id()?);

Get Model instance in Json-line format.

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{}", output_data.json()?);

Get the creation date of the document.

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{}", output_data.created_at());

Get the date the document was updated.

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{}", output_data.updated_at());

Get errors message ( for user side ).

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

if output_data.is_valid() {
    println!("{}", output_data.err_msg());
}

Printing errors to the console ( for development ).

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

if output_data.is_valid() {
    output_data.print_err();
}

Get field type list in json-line format for admin panel. ( converts a field type map to a list, in the order of the Model fields )

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{}", output_data.json_for_admin()?);

Get/Set final document

Example:
let mut model_name = ModelName::new()?;

let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{:?}", output_data.get_doc());
println!("{:?}", output_data.set_doc(Some(new_doc)));

Get Model instance in serde_json::Value format.

Example:
let mut model_name = ModelName::new()?
;
let output_data = model_name.check()?;
// or
let output_data = model_name.save(None, None)?;

println!("{:?}", output_data.model_json());

Trait Implementations

Get prepared document ( converting data types to model-friendly formats ).
In the model instance, in the format serde_json::Value, Update the field type values from the corresponding document from the database. Read more
Get prepared documents ( missing fields type ).
Get json-line from document list ( missing fields type ).
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.