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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pouchdb-all-dbs

v1.1.1

Published

PouchDB allDbs plugin

Downloads

22,443

Readme

PouchDB allDbs() plugin

Build Status

This plugin exposes the PouchDB.allDbs() function, which you can use to list all local databases. It works by listening for PouchDB.on('created') and PouchDB.on('destroyed') events, and maintaining a separate database to store the names of those databases.

Note: allDbs() used to be part of PouchDB core (enabled using PouchDB.enableAllDbs = true). It was deprecated in PouchDB 2.0.0, and now lives on as a plugin.

Usage

In the browser

To use this plugin, include it after pouchdb.js in your HTML page:

<script src="pouchdb.js"></script>
<script src="pouchdb.all-dbs.js"></script>

This plugin is also available from Bower:

bower install pouchdb-all-dbs

Merely including it as a script tag will work, assuming you also used a script tag for PouchDB.

In Node/Browserify/Webpack/etc.

First, npm install it:

npm install pouchdb-all-dbs

And then do this:

var PouchDB = require('pouchdb');
require('pouchdb-all-dbs')(PouchDB);

API

PouchDB.allDbs([callback])

Returns a list of all non-deleted databases. Example usage as a promise:

PouchDB.allDbs().then(function (dbs) {
  // dbs is an array of strings, e.g. ['mydb1', 'mydb2']
}).catch(function (err) {
  // handle err
});

Or if you like callbacks, you can use that style instead:

PouchDB.allDbs(function (err, dbs) {
  if (err) {
    // handle err
  }
  // dbs is an array of strings, e.g. ['mydb1', 'mydb2']
});

PouchDB.resetAllDbs([callback])

Destroys the separate allDbs database. You should never need to call this function; I just use it for the unit tests.

Example usage:

PouchDB.resetAllDbs().then(function () {
  // allDbs store is now destroyed
}).catch(function (err) {
  // handle err
});

Building

npm install
npm run build

Testing

In Node

This will run the tests in Node using LevelDB:

npm test

You can also check for 100% code coverage using:

npm run coverage

If you have mocha installed globally you can run single test with:

TEST_DB=local mocha --reporter spec --grep search_phrase

The TEST_DB environment variable specifies the database that PouchDB should use (see package.json).

In the browser

Run npm run dev and then point your favorite browser to http://127.0.0.1:8001/test/index.html.

The query param ?grep=mysearch will search for tests matching mysearch.

Automated browser tests

You can run e.g.

CLIENT=selenium:firefox npm test
CLIENT=selenium:phantomjs npm test

This will run the tests automatically and the process will exit with a 0 or a 1 when it's done. Firefox uses IndexedDB, and PhantomJS uses WebSQL.