34 stable releases
1.7.8 | Sep 7, 2023 |
---|---|
1.6.7 | Jun 18, 2023 |
1.3.25-beta |
|
1.2.1-beta |
|
0.12.24 |
|
#339 in Database interfaces
240 downloads per month
Used in admin-gp
395KB
7K
SLoC
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 versions 4.2, 4.4, 5.0, 6.0
- 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
- rust-i18n
- metamorphose
Install mongodb (if not installed)
Follow the link Install MongoDB.
Usage:
Basic Example
Tests for examples
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_addition | false | Allows methods for additional actions and additional validation. |
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()
- add_actions()
- 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
License
This project is licensed under the MIT and Apache Version 2.0
Dependencies
~36–49MB
~870K SLoC