pouchdb-migrate

1.1.1 • Public • Published

pouchdb-migrate

PouchDB plugin for running migrations.

Setup

<script src="pouchdb.js"></script>
<script src="pouchdb.migrator.js"></script>

Or to use it in Node.js, just npm install it:

npm install pouchdb-migrate

And then attach it to the PouchDB object:

var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-migrate'));

Usage

var db = new PouchDB('mydb')
 
// Migration script
// * Return falsy value to skip the doc
// * Make sure to prevent from loops
var migration = function(doc) {
  if ('foo' in doc) return
 
  doc.foo = 'bar'
  return [doc]
}
 
db.migrate(migration)
  .then //... every doc has `foo` now

Testing

Run the tests with

npm test

Package Sidebar

Install

npm i pouchdb-migrate

Weekly Downloads

2

Version

1.1.1

License

Apache-2.0

Last publish

Collaborators

  • jo