A simple document style in-memory database that implements a RESTful HTTP API possessing limited compatibility with MongoDB query syntax.
Status | Task |
---|---|
- | Build out query system |
✔️ | Further define datastore model |
✔️ | Implement limited test coverage |
Status | Task |
---|---|
✔️ | Create architectural component diagram |
✔️ | Implement the data store component |
✔️ | Implement the HTTP API component |
RockumentDB implements a RESTful HTTP API.
Method | Path | Content-Type |
---|---|---|
GET | / | text/plain |
RockumentDB 2.0.0-alpha
Method | Path | Content-Type |
---|---|---|
POST | /api/v2/{collection} | application/json |
[
{
"username": "johnperry",
"email": "johnperry@example.com",
"first_name": "John",
"last_name": "Perry",
"age": 75
},
{
"username": "louiswu",
"email": "louiswu@example.com",
"first_name": "Louis",
"last_name": "Wu",
"age": 200
}
]
A list the newly created document Id's
[1, 2]
Method | Path | Content-Type |
---|---|---|
GET | /api/v2/{collection}?query={query} | application/json |
URL encoded query param using MongoDB style find query.
http://{{server}}/api/v2/test?query={username:"johnperry"}
[
{
"username": "johnperry",
"email": "johnperry@example.com",
"first_name": "John",
"last_name": "Perry",
"age": 75
}
]
Invalid queries return 400 and an empty array.
[]
Internal server issues return 500 and an empty array
[]
RockumentDB has a test suite written in Rust and Python. Unittests are
kept in their respective modules and are in Rust. HTTP API tests are
written in Python and are located in the tests
directory.
I highly recommend the Cargo Watch plugin for a TDD workflow.
cargo install cargo-watch
cargo watch -x "test -- --nocapture"
or on its own
cargo test
If you use VSCode as your editor you can create a task that runs your tests everytime you save. .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "cargo watch --watch src --poll --postpone --quiet --clear -x \"test -- --nocapture\"",
"problemMatcher": ["$rustc"],
"group": {
"kind": "test",
"isDefault": true
},
"label": "Rust: cargo watch test",
"presentation": {
"reveal": "always",
"clear": true
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
To test the HTTP API we use pytest
. It's a powerful testing framework
that's fast to iterate with. You will need Python 3.6+ to run these
tests.
bash
python -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt
pwsh
python -m venv venv
.\venv\Scripts\activate
python -m pip install -r requirements.txt
python -m pytest -vs tests
- RockumentDB's Rust Docs -
cargo doc --open
- Rocket Crate
- Serde
- Serde JSON