jsn-base

Crates.iojsn-base
lib.rsjsn-base
version0.1.0
sourcesrc
created_at2024-01-11 11:36:49.302617
updated_at2024-01-11 11:36:49.302617
descriptionA database, similar to `sqlite`. It supports reading and writing.
homepage
repositoryhttps://github.com/mdmahikaishar/jsn-base
max_upload_size
id1096205
size10,101
Md Mahi Kaishar (mdmahikaishar)

documentation

README

Jsn Base (JSON Base)

Rust License

Jsn Base is a database, similar to sqlite. It supports reading and writing.

Usage

Add this crate to your Cargo.toml file:

[dependencies]
jsn_base = "0.1.0"
use jsn_base::{Connection, Model};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct User {
    id: usize,
    name: String,
    email: String,
}

fn main() {
    let connection = Connection::new("my-app").unwrap();
    let mut model = Model::<User>::new("user", &connection);

    // load all previous datas
    model.load();

    // create a new data
    model.create(User {
        id: 0,
        name: String::from("Mahi"),
        email: String::from("email"),
    });

    // save current state of model
    model.save();

    // remove all
    model.removes(|_| true);

    // get specifice
    model.get(|user| user.id == 1);

    // get specifice users
    model.gets(|user| user.name.eq("Mahi"));

    // remove specifice
    model.remove(|user| user.name.eq("Mahi"));

    // remove some users
    model.removes(|user| user.name.eq("Me"));
}

Features

  • Modal.load(): Load previous state of data.

  • Modal.create(payload): Create a new record.

  • Modal.create(payloads): Create many new record.

  • Modal.save(): Save the current state of data.

  • Modal.get(fn): Get a single item.

  • Modal.gets(fn): Get many item.

  • Modal.remove(fn): Remove a sigle item.

  • Modal.removes(fn): Remove many item.

Contributing

Contributions are welcome! I would like you to contribute in this project.

Roadmap

This project is in its early stages, and there are many missing features that need implementation. Check the Issues section for a list of features, enhancements, and bug fixes that are planned.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 0

cargo fmt