jrdb

Crates.iojrdb
lib.rsjrdb
version0.0.2
sourcesrc
created_at2020-10-21 14:57:40.790697
updated_at2020-10-21 14:57:40.790697
descriptionDocument oriented database created for learning purpose
homepage
repositoryhttps://github.com/LeeJiaLe/jrdb
max_upload_size
id303848
size48,872
Deep Sea Lolicon (LeeJiaLe)

documentation

README

jrdb

Joel Rust Database, a document oriented NoSql database created for learning purpose

Currently support CRUD. Nested document/ collection and indexed collection not yet support.

Example usage:

use jrdb::jrdb_type::{AddGetValue, JrCollection, JrDocument};
use jrdb::Database;

use jrdb::{exp, jr_doc};

fn main() {
  //create file "main.db" if not exist
  let mut db: Database = Database::from("main");

  //use macro to create JrDocument
  let doc = jr_doc! {
    "name"; String => "Mathew".into(),
    "pass"; String => "ILoveERD".into(),
    "age"; i64 => 400,
  };

  //basic way to create JrDocument
  let mut doc2 = JrDocument::new();
  doc2.add_value("name", String::from("Joel"));
  doc2.add_value("pass", String::from("ILoveErd"));
  doc2.add_value("age", 30);

  //create collection "users" and admin if not exist
  db.insert("users", doc)
    .insert("admins", doc2)
    .execute();

  //update "users" with condition
  db.update(
    "users",
    jr_doc! {
      "name"; String => "Jason".into()
    },
  )
  .condition(exp! {"name" ;== "'Joel'"})
  .execute();

  //select "users"
  let collection: JrCollection = db.select("users").execute();
  collection.print(0);

  //select "admins"
  let collection: JrCollection = db.select("admins").execute();
  collection.print(0);

  //delete with condition
  db.delete("users")
    .condition(exp! {"name" ;== "'Jason'"})
    .execute();

  let collection: JrCollection = db.select("users").execute();
  collection.print(0);
}

Next Scope

  • Select data with specific key
  • Fix spaghetti code
  • Create documentation
Commit count: 11

cargo fmt