Logo

Green Barrel

ORM-like API MongoDB for Rust

To simulate fields of type ForeignKey and ManyToMany, a simplified alternative (Types of selective fields with dynamic addition of elements) is used.

crates.io crates.io crates.io crates.io

Attention

MongoDB tested on version 4.4

MongoDB Rust Driver updated as a dependency to version 2.

Requirements

Install mongodb (if not installed)

```shell

Ubuntu, Mint:

$ sudo apt install mongodb

OR

Ubuntu 20.04, Mint 20.x:

$ sudo apt update $ sudo apt install dirmngr gnupg apt-transport-https ca-certificates $ wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - $ sudo add-apt-repository 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse' $ sudo apt update $ sudo apt install mongodb-org $ sudo systemctl enable --now mongod

For check

$ mongod --version $ mongo --eval 'db.runCommand({ connectionStatus: 1 })' $ reboot #

Configuration file:

$ sudo nano /etc/mongod.conf #

Systemd:

$ sudo systemctl status mongod $ sudo systemctl start mongod $ sudo systemctl stop mongod $ sudo systemctl restart mongod $ sudo systemctl enable mongod $ sudo systemctl disable mongod #

Uninstall:

$ sudo systemctl stop mongod $ sudo systemctl disable mongod $ sudo apt --purge remove mongodb* # OR (for mongodb-org) - $ sudo apt --purge remove mongodb-org** $ sudo rm -r /var/log/mongodb $ sudo rm -r /var/lib/mongodb $ sudo rm -f /etc/mongod.conf $ sudo apt-add-repository --remove 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse' # for mongodb-org $ sudo apt update ```

Usage:

Basic Example

Model parameters

( all parameters are optional )

| Parameter: | Default: | Description: | | :------------------ | :----------- | :--------------------------------------------------------------------------------------------------- | | dbquerydocslimit | 1000 | limiting query results. | | isadddoc | true | Create documents in the database. false - Alternatively, use it to validate data from web forms. | | isupdoc | true | Update documents in the database. | | isdeldoc | true | Delete documents from the database. | | ignorefields | empty string | Fields that are not included in the database (separated by commas). | | isuseaddvalid | false | Allows additional validation - impl AdditionalValidation for ModelName. | | isuse_hooks | false | Allows hooks methods - impl Hooks for ModelName. |

Road map

Field types

See documentation -fields.

Methods for Developers

Main

Caching

Control

AdditionalValidation

Hooks

QCommons

QPaladins

Fixtures

Changelog

License

This project is licensed under the MIT and Apache Version 2.0