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
GET /info
GET /stats
GET /collection
POST /collection?name=$collectionname_
DELETE /collection/$collectionname_
GET /collection/$collectionname_/index
POST /collection/$collectionname/index?name=$fieldname&kind=$indexkind&type=$keytype
DELETE /collection/$collectionname/document/$indexname
GET /collection/$collectionname/document?filter=$query&order=$ordering&offset=$skip&length=$take_
GET /collection/$collectionname?filter=$query&order=$ordering&offset=$skip&length=$take_
PUT /collection/$collectionname/document?filter=$query&modify=$modifications_
PATCH /collection/$collectionname?filter=$query&modify=$modifications_
DELETE /collection/$collectionname/document?filter=$query_
PUT /collection/$collectionname?filter=$query_
POST /collection/$collectionname_/document
POST /collection/$collectionname_
GET /collection/$collectionname/document/$documentid
GET /collection/$collectionname/$documentid
PUT /collection/$collectionname/document/$documentid
PUT /collection/$collectionname/$documentid
DELETE /collection/$collectionname/document/$documentid
DELETE /collection/$collectionname/$documentid
```rust extern crate actix; extern crate futures; extern crate tokio;
extern crate serde_derive;
extern crate serde_json;
extern crate ledb;
extern crate ledb_actix;
extern crate log; extern crate prettyenvlogger;
use actix::System; use futures::Future; use ledbactix::{Storage, StorageAddrExt}; use serdejson::from_value; use std::env; use tokio::spawn;
struct BlogPost {
pub title: String,
pub tags: Vec
fn main() { env::setvar("RUSTLOG", "info"); prettyenvlogger::init().unwrap();
let _ = std::fs::remove_dir_all("example_db");
System::run(|| {
let addr = Storage::new("example_db").unwrap().start(1);
spawn(
addr.clone().send_query(query!(
insert into blog {
"title": "Absurd",
"tags": ["absurd", "psychology"],
"content": "Still nothing..."
}
)).and_then({ let addr = addr.clone(); move |id| {
info!("Inserted document id: {}", id);
assert_eq!(id, 1);
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."
}
))
} }).and_then({ let addr = addr.clone(); move |id| {
info!("Inserted document id: {}", id);
assert_eq!(id, 2);
addr.send_query(query!(
index for blog tags string
))
} }).and_then({ let addr = addr.clone(); move |_| {
info!("Indexing is ok");
addr.send_query(query!(
find BlogPost in blog
where tags == "psychology"
order asc
))
} }).map(|mut docs| {
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!({
"title": "Absurd",
"tags": ["absurd", "psychology"],
"content": "Still nothing..."
})).unwrap();
assert_eq!(doc.get_data(), &doc_data);
assert!(docs.next().is_none());
System::current().stop();
}).map_err(|err| {
error!("Error: {:?}", err);
})
);
});
} ```