npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

js-minidb

v1.0.6

Published

A simple file based database system, that can be created just by installing this package ( No setup required )

Readme

js-minidb

A lightweight, zero-dependency, JSON-based local database for Node.js projects. Inspired by MongoDB, js-minidb offers an intuitive API for managing databases, collections, and documents — all stored in a single JSON file on your disk.

Perfect for CLI tools, prototypes, small-scale applications, offline-first apps, or any use case where simplicity and local persistence matter.


  • 📦 Installation

  • 🧰 Features

  • 🔤 Syntax for each method

  • 🧪 Detailed examples

  • 🔍 Output expectations

  • 📚 API Reference

  • 💡 Notes and Best Practices


📦 Installation

npm install js-minidb

📁 How It Works

All data is stored in a single file named localdb.json in your project root. It contains multiple databases, each with collections and JSON objects.

Example structure:

{
  "myDB": {
    "users": [
      { "name": "Alice", "age": 25 },
      { "name": "Bob", "age": 30 }
    ]
  }
}

🧰 Features

  • Databases and collections (MongoDB-style)

  • Auto-creates databases and collections if missing

  • File-based persistent storage

  • Easy document operations

  • Zero external dependencies


✨ Usage

1. Import the module

const db = require('js-minidb');

🔤 Syntax & Examples

📥 insertOne(database, collection, object)

Inserts a single document.

db.insertOne('company', 'employees', { name: 'Alice', role: 'Engineer' });

📥 insertMany(database, collection, arrayofobjects)

Inserts an array of documents.

db.insertMany('usersDB', 'users', [{ username: 'jane', age: 30 }, { username: 'john', age: 22 }]);

🔍 find(database, collection, queryObject)

Finds all matching documents.

db.find('company', 'employees', { role: 'Engineer' });
// → [{ name: 'Alice', role: 'Engineer' }]

Matching is done with strict equality (===).


✏️ updateOne(database, collection, queryObject, updateObject)

Updates the first matching document.

db.updateOne('company', 'employees', { name: 'Alice' }, { role: 'Senior Engineer' });

✏️ updateMany(database, collection, queryObject, updateObject)

Updates all matching documents.

db.updateMany('company', 'employees', { role: 'Engineer' }, { department: 'Tech' });

deleteOne(database, collection, queryObject)

Deletes the first document that matches.

db.deleteOne('company', 'employees', { name: 'Alice' });

deleteMany(database, collection, queryObject)

Deletes all matching documents.

db.deleteMany('company', 'employees', { department: 'Tech' });

🧾 findLast(database, collection)

Returns the last inserted document in the collection.

const lastEmployee = db.findLast('company', 'employees');
console.log(lastEmployee);

🏗️ createDatabase(databaseName)

Creates a new database (not necessary — handled automatically).

db.createDatabase('school');

📂 createCollection(databaseName, collectionName)

Creates a new collection (not necessary — handled automatically).

db.createCollection('school', 'students');

📚 API Reference

Function

Description

insertOne(db, collection, obj)

Adds a new document

insertMany(db, collection, objarr)

Adds an array of objects into the collection

find(db, collection, query)

Retrieves matching documents

updateOne(db, collection, query, update)

Updates first match

updateMany(db, collection, query, update)

Updates all matches

deleteOne(db, collection, query)

Deletes first match

deleteMany(db, collection, query)

Deletes all matches

findLast(db, collection)

Returns last inserted object

createDatabase(name)

Manually creates database

createCollection(db, name)

Manually creates collection


📁 localdb.json File

  • File auto-generated in your project root

  • Do not manually edit unless necessary

  • You can delete it to reset your data


⚠️ Notes

  • Matching is done with shallow equality ({ key: value })

  • No indexing or performance optimization (keep small)

  • File I/O is synchronous (for simplicity)


🧪 Example Project

const db = require('js-minidb');

// Insert users
db.insertOne('usersDB', 'users', { username: 'john', age: 22 });
db.insertOne('usersDB', 'users', { username: 'jane', age: 30 });

//insert many
db.insertMany('usersDB', 'users', [{ username: 'jane', age: 30 }, { username: 'john', age: 22 }]);


// Update one
db.updateOne('usersDB', 'users', { username: 'john' }, { age: 23 });

// Find users
const results = db.find('usersDB', 'users', { age: 23 });
console.log(results);

// Delete one
db.deleteOne('usersDB', 'users', { username: 'jane' });

💡 Ideal For

  • Node.js scripts or tools

  • Electron apps

  • CLIs

  • Offline storage

  • Rapid prototyping

  • Educational use


🧑‍💻 Author

Adithyan
GitHub: @AdithyanSPillaiOfficial


📄 License

MIT License

Would you like me to generate this as a file and zip it for you? Or prepare a GitHub-ready release with `package.json` and `README.md` included?