Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eHealthAfrica/pouchdb-migrate

PouchDB plugin for running migrations.
https://github.com/eHealthAfrica/pouchdb-migrate

Last synced: 5 days ago
JSON representation

PouchDB plugin for running migrations.

Awesome Lists containing this project

README

        

# pouchdb-migrate
PouchDB plugin for running migrations.

[![Build
Status](https://travis-ci.org/eHealthAfrica/pouchdb-migrate.svg?branch=master)](https://travis-ci.org/eHealthAfrica/pouchdb-migrate)

## Setup
```html

```

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

```
npm install pouchdb-migrate
```

And then attach it to the `PouchDB` object:

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

## Usage
```js
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
```sh
npm test
```