Skip to content

An alternative Waterline/Sails adapter for couch db. Implements a single database model.

License

Notifications You must be signed in to change notification settings

arunp0/sails-couch-alt

 
 

Repository files navigation

image_squidhome@2x.png

sails-couch-alt

Provides an alternate access mechanism to Apache Couchdb from Sails.js & Waterline.

The core idea is,

Create a single database for all models (than one database per model) Identify models by an doc_type attribute Create a doc_type == 'metadata' document for each document type (Analogous to _design docs) Automatically generate simple indexed views that is accessible from the find function (Inspired by the original couchdb adapter) Ability to switch between all couch variants supported by nano

Installation

To install this adapter, run:

$ npm install sails-couch-alt (Not deployed in npm registry yet. Coming soon)

Usage

This adapter exposes the following methods:

find()

Find by id, find by where conditions. For each where condition, if a design doc is not present a new one is created, using a templated map funcion. TODO: Add more flexibility in creating views

create()

Does a nano.insert() by updating the id to _id column.

update()

Does a nano.insert taking into account the _rev property

destroy()

Finds the records specified by the where condition and, sets the _deleted property.

Interfaces

TODO: Support local instance of pouchDB. Currently only passing the basic tests, implement queryable interfaces completely Optimize for speed.

Running the tests

Configure the interfaces you plan to support (and targeted version of Sails/Waterline) in the adapter's package.json file:

{
  //...
  "sails": {
  	"adapter": {
	    "sailsVersion": "~0.10.0",
	    "implements": [
	      "semantic",
	      "queryable"
	    ]
	  }
  }
}

In your adapter's directory, run:

$ npm test

License

MIT © 2014 houm & [contributors] vipinr & contributors

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

About

An alternative Waterline/Sails adapter for couch db. Implements a single database model.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%