multi.dbx
v2.0.1
Published
Lightweight multi database with change watcher support.
Downloads
43
Maintainers
Readme
📂 JsonDB (multi.dbx)
A lightweight JSON database wrapper that feels like a mini NoSQL. Supports nested paths, deep filtering, and real-time file watching with events. Perfect for bots, logging, configs, and small projects. 🚀
![]()
![]()
![]()
![]()
![]()
Documentation
📦 Installation
npm install multi.dbx
# or
yarn add multi.dbx
# or
bun add multi.dbx📝 Changelog
v1.1.7 – Update
- ✅ Adding Json Schema
new Schema({ }) - ✅ Adding Async Function For Schema
await usersSchema["find", "get", "create", "getById", "update", "delete", "push"]
v2.0.0 – Plugins & Utilities
- ✅ Added Plugins System
- ✅ Added Hashing Utility
- ✅ Added JSON to CSV Export Function
🚀 Quick Start
import { JsonData } from "multi.dbx";
const db = new JsonData();
db.connect("database/pc.json");
db.set("user1", { name: "Black", points: 100 });Json Schema
- new Schema
import { Schema } from "multi.dbx";
const schema = new Schema(
{
user: { type: "string", required: true },
age: { type: "number", default: 18 },
},
"./database/users.json"
);- create a user
await schema.create({ user: "black" });
// Returns: { "user": "black", "age": 18 }- find a user
await schema.findById(schema._dbid);
await schema.find({ user: "dev" });- delete a user
await schema.delete(schema._dbid);
await schema.delete(schema._dbid, { age: 18 });👂 Real-time Events (Watcher)
import { JsonData, JsonWatcher } from "multi.dbx";
const db = new JsonData();
db.connect("database/pc.json");
const watcher = new JsonWatcher(db);
watcher.on("add", (e) => console.log("➕ Added:", e.diff?.added));
watcher.on("update", (e) => console.log("♻️ Updated:", e.diff?.updated));
watcher.on("remove", (e) => console.log("🗑️ Removed:", e.diff?.removed));
watcher.on("clear", () => console.log("⚠️ Database cleared"));
watcher.start();🔌 Plugins
- You can extend
multi.dbxfunctionality using plugins. - Example: Add custom validation, logging, or transformations.
import { JsonData } from "multi.dbx";
const db = new JsonData();
db.connect("database/pc.json");
// Example plugin usage
db.use(pluginFunction);🔐 Hash Utility
- Easily hash strings for passwords, IDs, or tokens.
import { hash } from "multi.dbx";
const hashed = hash("mySecretPassword");
console.log(hashed);📄 JSON to CSV
- Export your JSON data to CSV files.
import { ExcellFile } from "multi.dbx";
const db = new JsonData();
db.connect("database/users.json");
ExcellFile("users.csv", Object.values(db.getAll()));