@craftzdog/pouchdb-migrate

1.2.0 • Public • Published

pouchdb-migrate

PouchDB plugin for running migrations.

Build Status

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 @craftzdog/pouchdb-migrate

Weekly Downloads

0

Version

1.2.0

License

Apache-2.0

Unpacked Size

129 kB

Total Files

12

Last publish

Collaborators

  • craftzdog