Green Barrel
ORM-like API MongoDB for Rust
For simulate relationship Many-to-One and Many-to-Many, a simplified alternative (Types of selective fields with dynamic addition of elements) is used.
Attention
MongoDB tested on version 4.4
- Support for GreenPanel is temporarily unavailable.
Requirements
- mongodb
- serde
- chrono
- image
- lazy_static
- rand
- regex
- rust-argon2
- serde_json
- slug
- validator
- uuid
- async-lock
- async-trait
- futures
- tokio
- metamorphose
Install mongodb (if not installed)
Follow the link Install MongoDB.
Usage:
Model parameters
( all parameters are optional )
Parameter: | Default: | Description: |
---|---|---|
db_query_docs_limit | 1000 | limiting query results. |
is_add_doc | true | Create documents in the database. false - Alternatively, use it to validate data from web forms. |
is_up_doc | true | Update documents in the database. |
is_del_doc | true | Delete documents from the database. |
ignore_fields | empty string | Fields that are not included in the database (separated by commas). |
is_use_add_valid | false | Allows additional validation - impl AdditionalValidation for ModelName. |
is_use_hooks | false | Allows hooks methods - impl Hooks for ModelName. |
Links to Documentation
Field types
See documentation -fields.
Methods for Developers
- hash()
- set_hash()
- obj_id()
- set_obj_id()
- created_at()
- updated_at()
- meta()
- new()
- json()
- update_dyn_field()
- custom_default()
- add_validation()
- pre_create()
- post_create()
- pre_update()
- post_update()
- pre_delete()
- post_delete()
- create_index()
- drop_index()
- create_indexes()
- drop_indexes()
- aggregate()
- count_documents()
- delete_many()
- delete_one()
- distinct()
- drop()
- estimated_document_count()
- find_many_to_doc_list()
- find_many_to_json()
- find_one_to_doc()
- find_one_to_json()
- find_one_to_instance()
- find_one_and_delete()
- collection_name()
- namespace()
- check()
- save()
- delete()
- create_password_hash()
- verify_password()
- update_password()
- run_fixture()
Changelog
- v1.3.0 Field types - Changed attribute type error from String to Vec String.
- v1.2.0 Field types - Renamed pattern field attribute to regex. Added regex_err_msg attribute. See the documentation - https://docs.rs/green-barrel/latest/green_barrel/fields/index.html
- v1.1.0 Removed 12 types of fields, the remaining fields have been renamed. See the documentation - https://docs.rs/green-barrel/latest/green_barrel/fields/index.html
- v1.3.23-beta tz parameter removed from methods.
- v1.3.21-beta Trait AdditionalValidation - Transition to asynchronous code.
- v1.3.20-beta In all methods, the client parameter has been moved to the first position.
- v1.3.10-beta Main changes - Added methods for indexing.
- v1.3.6-beta Fixed checking of dates.
- v1.3.5-beta Improved dates checking.
- v1.3.2-beta Fixed basic example and updated readme file.
- v1.3.0-beta Transition to asynchronous code.
- v1.2.0-beta Updated dependency mongodb to version 2.
- v1.1.14-beta Rename Model parameters: is_add_docs, is_up_docs, is_del_docs to is_add_doc, is_up_doc, is_del_doc.
- v1.1.9-beta Tests updated and README.md file updated.
- v1.1.0-beta Added support for Fixtures - To populate the database with pre-created data.
- v1.0.16-beta Added parameter target_dir for field types InputFile and InputImage.
- v1.0.10-beta Updated comments for dynamic field types.
- v1.0.8-beta The 150 character limit has been removed from the update_dyn_field() method.
- v1.0.7-beta The administrator module has been removed and moved to a separate project.
- v1.0.0-beta Not compatible with green-barrel v0.x.x and metamorphose v0.x.x
- v0.12.14 Fixed README.md.
- v0.12.8 The db_update_dyn_widgets method has been renamed to update_dyn_wig and has been heavily modernized. See documentation: green-barrel > models > caching > Caching > update_dyn_wig.
- v0.12.4 Made two critical fixes to the check method and updated unit tests.
- v0.12.0 Deep modernization of the input_data module and related modules.
- v0.11.4 output_data module moved from widgets directory to models.
- v0.11.3 administrator module moved from db_query api directory to models.
- v0.11.2 Renamed methods in trait Administrator - instance_for_admin to actix_instance_for_admin and result_for_admin to actix_result_for_admin.
- v0.11.1 Added enum OutputDataAdmin for easier registration of Models in the administration panel.
- v0.11.0 Added trait Administrator for easier registration of Models in the administration panel.
- v0.10.100 Added new type UpdatePassword to enum OutputData. Updated documentation.
- v0.10.97 Added field attribute check - pattern.
- v0.10.95 For optimization, the output_data_to_html mediator function has been excluded.
- v0.10.94 Added the ability to customize html code for web forms. See documentation: mango_orm > widgets > generate_html > GenerateHtml > generate_html() > source.
- v0.10.93 Rename trait ToModel to Main.
- v0.10.92 Added arguments for to_html methods. Arguments: url_action, http_method and enctype. See documentation: mango_orm > widgets > output_data > OutputData > to_html.
- v0.10.90 For the OutputData enum, the output_data_to_html method is extended with the to_html alias.
- v0.10.20 Removed the ability to change the created_at field of a model instance.
- v0.10.0 The created_at and updated_at fields are automatically added to the Model. The widget type is inputDateTime and disabled = true, is_hide = true. Updated README.md. Updated documentation.
- v0.9.4-v.0.9.15 Import optimized.
- v0.9.0 Added hook methods. See documentation: mango_orm > models > hooks > Hooks.
- v0.8.26 Add find_one_to_wig method. See documentation: mango_orm > models > db_query_api > commons > QCommons.
- v0.8.0 Deep modernization of common.rs and output_data.rs modules. See documentation: mango_orm > models > db_query_api > commons > QCommons and mango_orm > models > output_data > Converters.
- v0.7.4 Updated README.md, added model attributes.
- v0.7.0 *Added the ability to use the hash field in inputSlug - slug_sources: r#"["hash", "username"]"#*
- v0.6.30 Renamed methods: wig(), json(), html() -> to_wig(), to_json(), to_html(). Updated README.md. Updated documentation. Updated versions of dependencies.
- v0.6.16 Renamed the Forms module to Widgets.
- v0.6.15 Updating by version of dependencies.
- v0.6.10 Updated test for dynamic widgets.
- v0.6.7 Removed hiddenSlug field.
- v0.6.6 Added is_hide parameter for Widgets.
- v0.6.5 In the check() method, errors are redirected to the console, for fields of hidden type.
- v0.6.4 Fixes for fields of slug type.
- v0.6 1) Added inputSlug and hiddenSlug fields. 2) Fix - Added fields of hidden type to migration.
- v0.5.4 Optimization for creating thumbnails, for default images.
- v0.5.3 Improved cleaning of orphaned files.
- v0.5 Support for the Form macro has been removed.