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

@cotter45/jsdb

v2.0.6

Published

A persistent JSON database for node.js

Downloads

16

Readme

JSDB

A lightweight, file-based JSON database manager for Node.js. This is especially useful for small-scale applications, prototyping or for when a full-blown database setup is unnecessary.

Features

  • Supports basic CRUD operations (Create, Read, Update, Delete) as well as full text search on JSON collections.
  • Each collection is managed separately, allowing for high flexibility.
  • Asynchronous operations using Promises.
  • File-based storage, each collection is created in it's own directory and manages it's own documents.
  • Data consistency is ensured by using a promise-based queue to manage operations.

Installation

Install via npm:

npm install @cotter45/jsdb

Usage

import JSDB from '@cotter45/jsdb';

// Initialize JSDB with an absolute or relative path
// This will create a new database if it doesn't exist
// or load an existing one if it does
const db = new JSDB('./data');

// Create a collection, specify the name and the maximum size of each document in bytes - default is 100KB
// If the collection already exists, it will be loaded
const users = db.createCollection('users', 10 * 1024 * 1024);

// Mthods on collections are async
const user = await users.insert({
  name: 'Alice',
  email: '[email protected]',
});

// Delete a collection
await db.deleteCollection('users');

Collection Operations

Operations on a collection can be performed using the methods provided by the JsonCollectionManager class. For example:

Create the collection first

import JSDB from '@cotter45/jsdb';

// Initialize JSDB with an absolute or relative path
const db = new JSDB('./data');

// Create a collection
const users = db.createCollection('users');

Insert

// Insert a record, automatically generates an id<number>
const insertUser = await users.insert({
  name: 'Alice',
  email: '[email protected]',
});
// insertUser = { id: 1, name: 'Alice', email: 'alice@wonderland' }

Get

// Get a record, will throw an error if the record doesn't exist
const getUser = await users.get(1);
// getUser = { id: 1, name: 'Alice', email: 'alice@wonderland' }

Update

// Update a record, don't change the id and report a bug please...
const updateUser = await users.update(1, {
  name: 'Bob',
  email: '[email protected]',
});
// updateUser = { id: 1, name: 'Bob', email: 'bob@example' }

Delete

// Delete a record, will return the deleted record
const deleteUser = await users.delete(1);
// deleteUser = { id: 1, name: 'Bob', email: 'bob@example' }

Search

// Search for records using Fuse.js
// Limit and offset are optional
const searchUser = await users.search('bob@exa', {
  keys: ['email'],
  limit: 1,
  offset: 0,
});
// searchUser = [{ id: 1, name: 'Bob', email: 'bob@example' }]

Where

// Custom filter function, passed as callback to Array.filter()
// Limit, offset, and order are optional
const whereUser = await users.where({
  filter: (user) => user.name === 'Bob',
  limit: 1,
  offset: 0,
  order: 'desc',
});
// whereUser = [{ id: 1, name: 'Bob', email: 'bob@example' }]

API Documentation

More detailed API documentation is available in the source code in the form of JSDoc comments.

Contribution

Contributions are always welcome. Please make sure that your code follows the existing coding style, and don't forget to add tests for your changes.

License

JSDB is released under the MIT License.