waterline-pouchdb

0.1.4 • Public • Published

image_squidhome@2x.png

waterline-pouchdb

Dependency Status

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.

Installation

To install this adapter, run:

$ npm install waterline-pouchdb

Config the entry in config/connections.js:

//...
  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 path.

Usage

Use in a model models/ExampleModel.js specifying the adapter defined above:

module.exports = {
  adapter: 'pouch',
  //...
  id: {
    primaryKey: true,
    type: 'string'
  },
  attributes: {
    name: 'string',
    //...
  }
}

Or set "pouch" as the default adapter for all models, in config/models.js:

module.exports.models = {
  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', //optional
    sync:{
      protocol: 'http',
      host: 'localhost',
      port: '5984',
      user: '_user',
      password: '_password',
    },                        
  }
//...

This adapter exposes the following methods:

find()
  • Status
    • Planned
create()
  • Status
    • Planned
update()
  • Status
    • Planned
destroy()
  • Status
    • Planned

Interfaces

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.

Development

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.

Getting started

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:

  1. Fork this repository
  2. Set up your README.md and package.json file. Sails.js adapter module names are of the form sails-*, where * is the name of the datastore or service you're integrating with.
  3. Build your adapter.

Questions?

See FAQ.md.

More Resources

License

MIT Copyright 2016 balderdashy & [contributors] Mike McNeil, Balderdash, Robin Millette, Juan José Ramírez Glz & contributors

Sails is free and open-source under the MIT License.

Dependencies (6)

Dev Dependencies (1)

Package Sidebar

Install

npm i waterline-pouchdb

Weekly Downloads

3

Version

0.1.4

License

MIT

Last publish

Collaborators

  • jaun
  • millette