Package Exports
- alisa.db
Readme
Source file
Creator(s)
Social media accounts
How to download?
First we create a node.js file (If you have not downloaded node.js to computer before, you can download node.js by clicking here)
Then we open the PowerShell terminal by "shift + right click" on the folder of the file you created.
- Then we write npm i alisa.db and press enter.
- And now we have downloaded the alisa.db module, congratulations 🎉🎉
alisa.db
A blazing-fast, feature-rich and fully customizable local JSON database module for Node.js projects.
📦 Installation
npm install alisa.db
✨ Features
- Type-safe, event-driven architecture
- Built-in cache support for better performance
- Auto write functionality (or manual save via
.writeAll()
) - Full support for multiple files
- Rich utility methods: CRUD, math ops, array ops, filter/search, etc.
- Built-in event system:
.on()
,.off()
,.emit()
- TypeScript & ESM support (types included)
🚀 Getting Started
Initialization
const AlisaDB = require("alisa.db");
// Using string
const db = new AlisaDB("database.json");
// Using config object
const db = new AlisaDB("data.json", {
autoWrite: true,
cache: true,
spaces: 2
});
CRUD Operations
db.set("username", "Fearless");
db.get("username"); // "Fearless"
db.has("username"); // true
db.delete("username");
db.get("username", "Anonymous"); // default fallback
Bulk Operations
db.setMany({ x: 1, y: 2, z: 3 });
db.getMany(["x", "z"]); // { x: 1, z: 3 }
db.deleteMany(["x", "y"]);
db.deleteAll();
Array Utilities
db.push("roles", "admin");
db.pushAll("roles", ["mod", "dev"]);
db.pop("roles");
db.unshift("roles", "founder");
db.shift("roles", 2);
Mathematical Modifiers
db.set("coins", 100);
db.add("coins", 50);
db.substr("coins", 30);
db.multi("coins", 2);
db.division("coins", 4);
Advanced Queries
db.find((key, value) => value === "admin");
db.filter((key, value) => typeof value === "number");
db.findAndDelete((k, v) => v === 0);
db.filterAndDelete((k, v) => k.startsWith("temp"), 3);
Introspection & Export
db.toJSON(); // Full object
db.toArray(); // Object.entries()
db.keys(); // All keys
db.values(); // All values
db.typeof("roles"); // "array"
File Management
db.clone("backup.json");
db.reset();
db.destroy();
db.create("newfile.json", { hello: "world" }, true);
📡 Event System
AlisaDB provides a fully extensible event system. Every change, read, write, or delete operation can trigger a custom listener.
You can track nearly everything:
db.on("get", ({ key, value }) => console.log("Accessed", key, value));
db.on("delete", ({ key }) => console.warn("Deleted:", key));
This is very useful for:
- Debugging database activity
- Logging or auditing file changes
- Reacting to specific state changes (e.g. auto-backup on set)
All listener callbacks receive an object with contextual information. For example:
{
fileName: "db.json",
file: { /* The file */ }
key: "userId",
value: "Storme",
isFound: true,
rawData: "Storme"
}
You can listen to any change happening in the database:
db.on("set", ({ key, value }) => {
console.log(`Set ${key} =`, value);
});
db.set("user", "Ali"); // triggers the above listener
Remove listeners with:
const fn = console.log;
db.on("delete", fn);
db.off("delete", fn);
Supported events: set
, get
, delete
, push
, add
, writeFile
, writeCache
, reset
, destroy
, clone
, create
, etc.
💾 Auto Write & Cache
const db = new AlisaDB("database.json", { autoWrite: true, cache: true });
// Or manually save changes to disk:
db.writeAll();
🧩 Multi-file support
db.set("greeting", "hello", "english.json");
db.set("greeting", "merhaba", "turkish.json");
You can manage unlimited JSON files via fileName
parameters.
🔧 Utility Methods
db.has("key");
db.hasAny(["k1", "k2"]);
db.hasAll(["k1", "k2"]);
db.getMany(["k1", "k2"]);
db.getFromValue("Ali");
db.filter((k, v) => typeof v === "number");
And finally
If you want to support this module, if you request me on github, I will be happy to help you.
Thank you for reading this far, i love you 💗
See you in my next modules!