Skip to content

jo/pouchdb-migrate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

PouchDB plugin for running migrations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%