allDbs() plugin for PouchDB
Clone or download
Latest commit a90d0b1 Jun 16, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin fix test setup Jun 15, 2016
dist build Jun 16, 2016
lib (#22) - fix pouchdb 5.4.x incompatibility Jun 15, 2016
test fix test setup Jun 15, 2016
.gitignore Initial commit Jun 1, 2014
.jshintrc Initial commit Jun 1, 2014
.npmignore add .npmignore Jun 9, 2014
.travis.yml skip testing in firefox Jun 16, 2016
LICENSE add license Oct 9, 2015 Update Apr 1, 2016
bower.json 1.0.1 Dec 12, 2014
package.json 1.0.2 Jun 16, 2016

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.


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');



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']


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


npm install
npm run build


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

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.