@imjxsx/localdb
v1.1.1
Published
A lightweight MongoDB-style BSON database for Node.js
Maintainers
Readme
@imjxsx/localdb
A lightweight MongoDB-style BSON database for Node.js
Fast, fully-typed, zero-dependency storage backed by BSON files.
Ideal for small apps, CLIs, bots, desktop tools, configs, caching, and offline data.
📦 Installation
npm i @imjxsx/localdb
pnpm add @imjxsx/localdb
yarn add @imjxsx/localdb
bun add @imjxsx/localdb🚀 Example of use
import { LocalDB, IDocument } from "@imjxsx/localdb";
interface IUser extends IDocument {
name: string;
level: number;
}
const db = new LocalDB("data").db("app");
// Load file
await db.load();
// Obtain the collection or create it if it doesn't exist
const users = db.collection<IUser>("users");
// Insert
users.insertOne({ name: "Jxsx", level: 50 });
users.insertOne({ name: "Luz", level: 20 });
// Query
console.log(users.findOne({ name: "Jxsx" }));
console.log(users.find({ level: 20 }));
// Update
users.updateOne({ name: "Luz" }, { level: 30 });
// Delete
users.deleteOne({ name: "Jxsx" });
// Save file
await db.save();🛠 Requirements
- Node.js >= 20.0.0
- TypeScript (optional but recommended)
📜 License
MIT © 2025 — Created & maintained by
