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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cache-database

v1.3.3

Published

cache database

Downloads

9

Readme

cache-database

Connection

  const cache = require('cache-database');

Collections

Create

  const collection = cache.create('collection');

Documents

Create

  //Return Promise.
  collection.create({a: 1, b: 2, c: 3})
    .then(() => console.log('ok'))
    .catch(error => console.log(error))

Find

  • Find all
  //Find all documents
  collection.find()
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */
  
  • Find params
  //Find for documents where a == 1;
  collection.find({a: 1})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find for documents where a == 1, b == 2
  collection.find({a: 1, b: 2})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find for documents where a == 1, a == 2, a == 3
  collection.find({a: {$in: [1,2,3]}})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find for documents where a >= 1 and a <= 4
  collection.find({a: {$gte: 1, $lte:4}})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find for documents where a > 1 and a < 4
  collection.find({a: {$gt: 1, $lt:4}})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find all documents and skip fields b in documents
  collection.find({}, {b: 0})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find all documents and sorting field a
  collection.find({}, {}, {a: 1})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  //AND REVERSE
  collection.find({}, {}, {}, {a: -1})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Find for documents starting at 30 and limit output to 10 documents
  collection.find({}, {}, 30, 10)
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

Search

  //Full-text document search
  collection.search('test')
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document search where a == 1
  collection.search('test', {a: 1})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document search where a == 1, a == 2, a == 3
  collection.search('test', {a: {$in: [1,2,3]}})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document search where a >= 1 and a <= 4
  collection.search('test', {a: {$gte: 1, $lte:4}})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document search where a > 1 and a < 4
  collection.search('test', {a: {$gt: 1, $lt:4}})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document search and skip fields b in documents
  collection.search('test', {}, {b: 0})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document search and sorting field a
  collection.search('test', {}, {}, {a: 1})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  //AND REVERSE
  collection.search('test', {}, {}, {a: -1})
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

  //Full-text document starting at 30 and limit output to 10 documents
  collection.search('test', {}, {}, 30, 10)
    .then(data => console.log(data))
    .catch(err => console.log(err));
  /*
    Return Promise. Resolve return Object, type:
    {
      data: Array,
      search: Array,
      skip: Array,
      sort: Array,
      records: {
        all: Number,
        skip: Number || null,
        limit: Number || null,
      },
    }
  */

Find One

  //Find document where a == 1;
  //Return Promise. Resolve return document
  collection.findOne({a: 1})
    .then(data => console.log(data))
    .catch(err => console.log(err));

  //Find document where a == 1, b == 2
  //Return Promise. Resolve return document
  collection.findOne({a: 1, b: 2})
    .then(data => console.log(data))
    .catch(err => console.log(err));

  //Find document where a == 1, a == 2, a == 3
  //Return Promise. Resolve return document
  collection.findOne({a: {$in: [1,2,3]}})
    .then(data => console.log(data))
    .catch(err => console.log(err));

  //Find document where a >= 1 and a <= 4
  //Return Promise. Resolve return document
  collection.findOne({a: {$gte: 1, $lte:4}})
    .then(data => console.log(data))
    .catch(err => console.log(err));

  //Find document where a > 1 and a < 4
  //Return Promise. Resolve return document
  collection.findOne({a: {$gt: 1, $lt:4}})
    .then(data => console.log(data))
    .catch(err => console.log(err));

  //Find document and skip fields b in documents
  //Return Promise. Resolve return document
  collection.find({}, {b: 0})
    .then(data => console.log(data))
    .catch(err => console.log(err));

Update

  //Return Promise.
  collection.findAndUpdate({a: 1}, {x: 10})
    .then(() => console.log('ok'))
    .catch(err => console.log(err));

Delete

  //Return Promise.
  collection.findAndDelete({a: 1})
    .then(() => console.log('ok'))
    .catch(err => console.log(err));