Provides easy access to
pouchdb from Sails.js & Waterline.
This module is a Waterline/Sails adapter, an early implementation of a rapidly-developing, tool-agnostic data standard. Its goal is to provide a set of declarative interfaces, conventions, and best-practices for integrating with all sorts of data sources. Not just databases-- external APIs, proprietary web services, or even hardware.
Strict adherence to an adapter specification enables the (re)use of built-in generic test suites, standardized documentation, reasonable expectations around the API for your users, and overall, a more pleasant development experience for everyone.
To install this adapter, run:
$ npm install waterline-pouchdb
Config the entry in
//...pouch:adapter: 'waterline-pouchdb'path: './tmp' //optional//...
By default, the database location is
/tmp/pouchDB. If you need to change the location add the field
Use in a model
models/ExampleModel.js specifying the adapter defined above:
moduleexports =adapter: 'pouch'//...id:primaryKey: truetype: 'string'attributes:name: 'string'//...
Or set "pouch" as the default adapter for all models, in
moduleexportsmodels =connection: 'pouch';
If you need to sync with a couchDB (for example, in http://localhost:5984/ with a specific user
_user and password
_password) add in config/connections.js the sync field:
//...pouch:adapter: 'waterline-pouchdb'path: './tmp' //optionalsync:protocol: 'http'host: 'localhost'port: '5984'user: '_user'password: '_password'//...
This adapter exposes the following methods:
TODO: Specify the interfaces this adapter will support. e.g.
This adapter implements the [semantic]() and [queryable]() interfaces.For more information, check out this repository's FAQ and the adapter interface reference in the Sails docs.
Check out Connections in the Sails docs, or see the
config/connections.js file in a new Sails project for information on setting up adapters.
It's usually pretty easy to add your own adapters for integrating with proprietary systems or existing open APIs. For most things, it's as easy as
require('some-module') and mapping the appropriate methods to match waterline semantics. To get started:
- Fork this repository
- Set up your
package.jsonfile. Sails.js adapter module names are of the form sails-*, where * is the name of the datastore or service you're integrating with.
- Build your adapter.