Skip to content

A Feathers service adapter for CouchDB using Apache CouchDB Nano driver.

License

Notifications You must be signed in to change notification settings

pdxbmw/feathers-couchdb-nano

Repository files navigation

feathers-couchdb-nano

Build Status Code Climate Test Coverage Dependency Status Download Status

Feathers CouchDB adapter service using Apache CouchDB Nano.

Installation

npm install feathers-couchdb-nano --save

Documentation

Please refer to the Feathers database adapter documentation for more general details.

Options

Name Type Description
connection Object Instance of CouchDB Nano connection.
db String Name of CouchDB database.
events Array List of custom service events sent by this service.
id String Name of id field property (defaults to _id).
name String Name of CouchDB document type (for generating ids and querying).
paginate Object Pagination object containing default and max page size.

Complete Example

Here's an example of a Feathers server that uses feathers-couchdb-nano.

const feathers = require('feathers');
const rest = require('feathers-rest');
const hooks = require('feathers-hooks');
const bodyParser = require('body-parser');
const errorHandler = require('feathers-errors/handler');
const plugin = require('feathers-couchdb-nano');
const nano = require('nano');

// Connect to CouchDB
const connection = nano('http://localhost:5984');

// Specify the plugin options
const options = {
  connection: connection,
  db: 'mydb',
  id: 'id',
  name: 'mydoctype',
  paginate: {
    default: 10,
    max: 25
  }
};

// Initialize the application
const app = feathers()
  .configure(rest())
  .configure(hooks())
  // Needed for parsing bodies (login)
  .use(bodyParser.json())
  .use(bodyParser.urlencoded({ extended: true }))
  // Initialize the feathers plugin
  .use('/plugin', plugin(options))
  .use(errorHandler());

app.listen(3030);

console.log('Feathers app started on 127.0.0.1:3030');

Todo

  • Create databases (unless existent)
  • Create and update design documents
  • Integrate couchdb-bootstrap?

License

Copyright (c) 2017

Licensed under the MIT license.

About

A Feathers service adapter for CouchDB using Apache CouchDB Nano driver.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published