NanoDB
Simple lightweight, pure-rust, high-performance and easy to use local JSON database.
What is NanoDB
NanoDB is a simple, lightweight, and easy-to-use JSON database for Rust. It is designed to be used in small to medium-sized projects where a full-fledged database is not necessary. It is built on top of the serde_json
crate and provides a simple and easy-to-use API for reading and writing JSON data.
Examples
use NanoDB;
// Init a new database
let mut db = open?;
// In memory data manipulation
db.insert?;
db.insert?;
db.insert?;
db.insert?;
db.insert?;
db.insert?;
// Write data to the file
db.write?;
// Simple getter
let age: i64 = db.get?.into?;
let city: String = db.get?.get?.into?;
let fruits_value_tree: String = db.get?.at?.into?;
let address: = db.get?.into?;
// Tree method (a tree consists of a part of the JSON object contained in the database)
let number_of_fruits = db.get?.len?;
let fruits = db.get?.push?;
let numbers = db
.get?
.for_each?;
// Merge (after manipulation, the tree can be merged back into the database)
db.merge?;
let fruits = db.get?.push?;
db.merge?;
let address = db.get?.insert?;
db.merge_and_write?;