pouchdb-hoodie-api
Hoodie-like API for PouchDB
This plugin provides simple methods to add, find, update and remove data.
Usage
Initialisation
var db = 'dbname'var api = db
API
// Options// emitter: Optionally pass an instance of EventEmitter for hoodieApi to use var db = 'dbname'var api = db // all methods return promisesapiapiapiapi // with id propertyapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiapiclear // events// Important: the order of when the methods promises resolve and the events get// triggered cannot be guaranteed as we rely on PouchDB’s .changes().// We would love to enforce promises to resolve after changes get// emitted, but the required complexity to do that is not worth it.apiapiapiapiapiapiapi // returns an API with all methods above, but implicitly scoped to the passed// id prefix. Meaning events are only triggered for documents that match the id// prefix, and documents are not found unless they have the id prefix.// See https://github.com/hoodiehq/discussion/issues/106 for more context.var todoStore = apitodoStoretodoStore // original PouchDB (http://pouchdb.com/api.html) instance used for the storeapidb
Full API documentation is available at: http://hoodiehq.github.io/pouchdb-hoodie-api/
Installation
Install via npm
npm install pouchdb
npm install pouchdb-hoodie-api
Including the plugin
With browserify or on node.js
Attach this plugin to the PouchDB
object:
var PouchDB = PouchDB
In the browser
Include this plugin after pouchdb.js
in your HTML page:
Testing
In Node.js
Run all tests and validates JavaScript Code Style using standard
npm test
To run only the tests
npm run test:node
In the browser
test:browser:local
This will start a local server. All tests and coverage will be run at http://localhost:8080/__zuul
Contributing
Have a look at the Hoodie project's contribution guidelines. If you want to hang out you can join #hoodie-pouch on our Hoodie Community Slack.