1.1.1 • Published 10 years ago
pouchdb-migrate v1.1.1
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-migrateAnd 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` nowTesting
Run the tests with
npm test