34 stable releases

1.7.8 Sep 7, 2023
1.6.7 Jun 18, 2023
1.3.25-beta Dec 21, 2022
1.2.1-beta Nov 27, 2022
0.12.24 Aug 10, 2022

#171 in Database interfaces

Download history 13/week @ 2023-11-01 113/week @ 2023-11-08 5/week @ 2023-11-15 120/week @ 2023-11-22 379/week @ 2023-11-29 1/week @ 2023-12-06 113/week @ 2023-12-13 110/week @ 2023-12-20 111/week @ 2023-12-27 34/week @ 2024-01-03 3/week @ 2024-01-10 12/week @ 2024-01-17 111/week @ 2024-01-24 221/week @ 2024-01-31 1/week @ 2024-02-07 796/week @ 2024-02-14

1,141 downloads per month
Used in admin-gp

MIT/Apache

395KB
7K SLoC

Logo

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.

crates.io crates.io Green Barrel on docs.rs crates.io crates.io

Attention

MongoDB tested on versions 4.2, 4.4, 5.0, 6.0

  • Support for GreenPanel is temporarily unavailable.

Requirements

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.

Field types

See documentation -fields.

Methods for Developers

Main

  • hash()
  • set_hash()
  • obj_id()
  • set_obj_id()
  • created_at()
  • updated_at()

Caching

  • meta()
  • new()
  • json()
  • update_dyn_field()

Control

  • custom()

Addition

  • add_actions()
  • add_validation()

Hooks

  • pre_create()
  • post_create()
  • pre_update()
  • post_update()
  • pre_delete()
  • post_delete()

QCommons

  • 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()

QPaladins

  • check()
  • save()
  • delete()
  • create_password_hash()
  • verify_password()
  • update_password()

Fixtures

  • run_fixture()

Changelog

View the change history.

License

This project is licensed under the MIT and Apache Version 2.0

Dependencies

~44–58MB
~1M SLoC