A replicating db.destroy() alternative for PouchDB
JavaScript
Clone or download
Permalink
Failed to load latest commit information.
dist Initial commit Dec 7, 2014
test Removes test data from npm package Dec 8, 2014
.gitignore Initial commit Dec 7, 2014
.jshintrc Initial commit Dec 7, 2014
.npmignore Removes test data from npm package Dec 8, 2014
.travis.yml Adds Travis testing Dec 7, 2014
README.md
index.js Initial commit Dec 7, 2014
package.json chore(package): update fs-extra to version 0.30.0 Apr 28, 2016

README.md

pouchdb-erase

Build Status Dependency Status devDependency Status

A replicating db.destroy() alternative for PouchDB. Works by iterating over all documents in the database and deleting them. Uses batches and changes() internally. It's a drop-in replacement for db.destroy().

Example

npm install pouchdb pouchdb-erase
//index.js
var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-erase'));

var db = new PouchDB('test');
db.erase().then(function (resp) {
	console.log(resp) //{ok: true}
})

Browser usage

<script src='dist/pouchdb-erase.min.js'></script>
<script>
  PouchDB.plugin(Erase);

  new PouchDB('test').erase();
</script>

API

  • db.erase([options[, callback]])

    the only option in options is at the moment batch_size, it determines how much documents are collected before they are removed all at once in one batch. callback is optional, as shown in the example a promise interface is also provided.