Skip to content

imjxsx/localdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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.

MIT License Node Version BSON Status


📦 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

About

A lightweight MongoDB-style BSON database for Node.js

Topics

Resources

License

Stars

Watchers

Forks