#actor #actor-framework #lmdb #rest #actix-actor #storage #json


LEDB Actor for Actix actor framework and storage REST-interface

6 releases (3 breaking)

0.4.0 Jun 11, 2020
0.3.0 Sep 6, 2019
0.2.1 Oct 27, 2018
0.1.1 Oct 1, 2018
0.1.0 Sep 28, 2018

#1823 in Database interfaces

41 downloads per month

MIT license


Actor and REST interface for LEDB

License: MIT Travis-CI Build Status Appveyor Build status Crates.io Package Docs.rs API Documentation

The LEDB is an attempt to implement simple but efficient, lightweight but powerful document storage.

The abbreviation LEDB may be treated as an Lightweight Embedded DB, also Low End DB, also Literium Engine DB, also LitE DB, and so on.


LEDB HTTP interface 0.1.0

Storage API

get database info

GET /info

get database statistics

GET /stats

Collection API

get list of collections

GET /collection

create new empty collection

POST /collection?name=_$collection_name_

drop collection with all documents

DELETE /collection/$collection_name

Index API

get indexes of collection

GET /collection/$collection_name/index

create new index for collection

POST /collection/$collection_name/index?path=_$field_name_&kind=_$index_kind_&key=_$key_type_

drop index of collection

DELETE /collection/$collection_name/document/$index_name

Document API

find documents using query

GET /collection/$collection_name/document?filter=_$query_&order=_$ordering_&offset=_$skip_&length=_$take_

GET /collection/$collection_name?filter=_$query_&order=_$ordering_&offset=_$skip_&length=_$take_

modify documents using query

PUT /collection/$collection_name/document?filter=_$query_&modify=_$modifications_

PATCH /collection/$collection_name?filter=_$query_&modify=_$modifications_

remove documents using query

DELETE /collection/$collection_name/document?filter=_$query_

PUT /collection/$collection_name?filter=_$query_

insert new document

POST /collection/$collection_name/document

POST /collection/$collection_name

get document by id

GET /collection/$collection_name/document/$document_id

GET /collection/$collection_name/$document_id

replace document

PUT /collection/$collection_name/document/$document_id

PUT /collection/$collection_name/$document_id

remove document

DELETE /collection/$collection_name/document/$document_id

DELETE /collection/$collection_name/$document_id

Supported index kinds

  • uni -- Unique key
  • dup -- Duplicated keys

Supported key types

  • int -- 64-bit signed integer
  • float -- 64-bit floating point number
  • bool -- boolean value
  • string -- UTF-8 string
  • binary -- binary data


Usage example

use std::env;

use serde::{Deserialize, Serialize};
use serde_json::json;

use ledb_actix::{query, Document, Options, Primary, Storage, StorageAddrExt};
use log::info;
use serde_json::from_value;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Document)]
struct BlogPost {
    pub id: Option<Primary>,
    pub title: String,
    pub tags: Vec<String>,
    pub content: String,

async fn main() {
    env::set_var("RUST_LOG", "info");

    let _ = std::fs::remove_dir_all("example_db");

    let addr = Storage::new("example_db", Options::default())

    let id = addr
            insert into blog {
                "title": "Absurd",
                "tags": ["absurd", "psychology"],
                "content": "Still nothing..."

    info!("Inserted document id: {}", id);
    assert_eq!(id, 1);

    let id = addr.send_query(query!(
        insert into blog {
            "title": "Lorem ipsum",
            "tags": ["lorem", "ipsum"],
            "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

    info!("Inserted document id: {}", id);
    assert_eq!(id, 2);

        index for blog tags string

    info!("Indexing is ok");

    let mut docs = addr
            find BlogPost in blog
            where tags == "psychology"
                order asc

    info!("Number of found documents: {}", docs.size_hint().0);

    assert_eq!(docs.size_hint(), (1, Some(1)));

    let doc = docs.next().unwrap().unwrap();

    info!("Found document: {:?}", doc);

    let doc_data: BlogPost = from_value(json!({
        "id": 1,
        "title": "Absurd",
        "tags": ["absurd", "psychology"],
        "content": "Still nothing..."

    assert_eq!(&doc, &doc_data);


~303K SLoC