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

@niellxu/jsdb

v1.1.1

Published

Fast and easy to use temporary database based on JSON

Readme

JSDB

npm version Build Status

JSDB is a fast and easy to use temporary database based on JSON. It can be useful in different scenarios such as storing data temporarily, testing frontend API call with mock response data, updating JSON files etc.

Get Started

There are different types of databases can be used and the most commonly used one is BasicDatabase. To create a new database and a table:

const { BasicDatabase } = require('@niellxu/jsdb').Database;
const datbase = new BasicDatabase();
database.create('example');

Then you can perform CRUD operations like any other databases

database.use('example')     // Remember to use the table "example"
const example = {
    key: "X",
    value: "Y",
};
database.insert(example);   // Insert example into the table
database.read({});          // Read everything
database.update({           // Update data with key "X"
    key: "X"
}, {
    value: "G"
});
database.delete({})         // Delete everything

The query is designed to be similar with MongoDB except that it does not support too many identifiers (for now) like $set, $gt, $lt and so on.

Host

JSDB also supports the functionality to host the database on local using express.js. To start the database server, simply run:

jsdb   # or "jsdb --PORT=8080" if running on custom port

Then using the following URLs to communicate with the database:

|Method|URL|Comment| |------|---|-------| |GET|/create/{tableName}|Create a new table with given name| |GET|/drop/{tableName}|Drop a table with given name| |GET|/list|List all table names| |GET|/insert/{tableName}/{data}|Insert data into the table| |GET|/read/{tableName}/{query}?|Read all the data that match the query, or all data if query is not given| |GET|/update/{tableName}/{query}/{update}|Update the data that match the query| |GET|/delete/{tableName}/{query}?|Delete all the data that match the query, or all data if query is not given|

Testing

One of the use case of JSDB is to mock the data sent back from the backend when developing the frontend. We might want to retrieve the data with some delay as well since we are simulating a real call. In this case, promiseWrap and callbackWrap might be helpful:

const { promiseWrap, callbackWrap } = require('@niellxu/jsdb').Wrap;

// Wrap the database result in promise way with 1000ms delay
promiseWrap(database.read({}), 1000)
    .then(result => {
        console.log(result);
    });

// Wrap the database result in callback way with 1000ms delay
callbackWrap(database.read({}), (result) => {
    console.log(result);
}, 1000);

TODO

  • [ ] Add support of identifiers such as $gt, $lt
  • [ ] AsyncDatabase, every operation is async
  • [ ] SchemaDatabase, a database that based on schema instead of storing objects
  • [ ] ImmutableDatabase, immutable and produce new results in every step
  • [ ] UniqueDatabase, produce unique index for every document (like MongoDB ObjectID)
  • [x] Export database to JSON files
  • [x] Import database from JSON files
  • [x] Tests for host calls