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

jaguardb

v0.1.3

Published

The simplest in-process database for Node.js that could possible work.

Readme

jaguarDb

The simplest in-process database for Node.js that could possible work.

This library provides the ability to store information in a Node.js application emulating a simple document-oriented database and without requiring an external process to be running.

The goal is to provide a quick and dirty way of storing information for small prototypes and unit testing. Do not use this to power your web site or the next eBay.

The API mimics MongoDB’s API to allow for easy migration of applications using jaguarDb to a real database. Also, the fact the MongoDB has a kickass API makes it an great model to follow.

This database does not support transactions or any of the ACID properties. In fact you should not even consider it a database. It's basically a glorified wrapper around JSON.stringfy and JSON.parse tailored to mimic a database.

The API for jaguarDb is asynchronous so that the code using it can easily migrated to use a real database. I might provide a synchronous API later on to make its use much simpler, particularly for unit tests or batch processes.

Basic Samples

demoAdd.js shows how to add data to a brand new database. The basic structure is as follow.

var JaguarDb = require('./jaguarDb').JaguarDb;
var db = new JaguarDb();
db.connect('./data', function(err) {
  if(err) {
    // handle error
    return;
  }
  var data = {title: 'hello', content: 'blah blah blah'};
  db.insert(data, function(err, insertedData) {
    // insertedData has the new document
  });
});

demoFind.js shows how to query documents from the database. The basic structure is as follow:

var JaguarDb = require('./jaguarDb').JaguarDb;
var db = new JaguarDb();
db.connect('./data', function(err) {
  if(err) {
    // handle error
    return;
  }
  var query = {}; // all records
  var fields = {}; // all fields
  db.find(query, fields, function(err, documents) {
    // your data is in the documents array
  });
});

You can filter the documents by providing a query object with the fields and attributes to use to filter: The following example will select documents where the title is 'hello'

var query = { title: 'hello' };

Sample using Express

demoExpress.js shows how to use jaguarDb with Express.js. You need to install Express.js on your system via npm install express before running this example:

var express = require('express');
var app = express();

var JaguarDb = require('./jaguarDb').JaguarDb;
var db = new JaguarDb();

db.connect('./data', function(err) {
  if(err) {
    console.log('Could not connect to database: ' + err);
    return;
  }
});

app.get('/', function(req, res){
  var query = {}; // all records
  var fields = {}; // all fields
  db.find(query, fields, function(err, docs) {
    if(err) {
      res.send('Error reading documents: ' + err);
      return;
    }
    // build HTML with your documents
    var html = "";
    res.send(html);
  });
});

Storage

Data is stored in one directory per database. A master file "index.json" contains the list of documents in the database plus other general information about the database (e.g. list of indexes, list of ids, and list of indexed values.)

Each document is automatically assigned an _id field with a sequential value.

One individual JSON file is created for each document, these files are named "n.json" where n is the value of the _id for the document.

The structure of the index.json file is more or less as follows:

{
  "nextId":3,
  "indexes":["field1"],
  "documents":[
    {"_id":1,"field1":"valueA"},
    {"_id":2,"field1":"valueB"}
  ]
}

The structure of a document file (say 1.json) is more or less as follows:

{"_id":1, "field1"":"valueA","content":"blah blah blah"}

Limitations (a lot)

This library is meant to be used in a single-user environment as it has no multi-user provisions.

Transactions are not supported.

No sorting or aggregations are provided.

Except for findById, all find operations are sequential (i.e. no binary tree or btree are used for searching.)

Future enhancements

Add support for complex queries. Currently only exact match queries are allowed.

// This is currently supported
// filter where fieldA == 'a' and fieldB == 'b'
var query = {fieldA: 'a', fieldB: 'b'};

// This is NOT currently supported
// filter where fieldA == 'a' or fieldB == 'b'
// filter where fieldA > 'a'

Allow for sorting operations.

Questions, comments, thoughts?

This is a very rough work in progress.

Feel free to contact me at [email protected] with questions or comments about this project.