Feathers CouchDB adapter service using Apache CouchDB Nano.
npm install feathers-couchdb-nano --save
- Apache Couchdb Nano - The details of the underlying database driver
- Extending - How to extend a database adapter
- Pagination and Sorting - How to use pagination and sorting for the database adapter
- Querying - The common adapter querying mechanism
Please refer to the Feathers database adapter documentation for more general details.
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. |
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');
- Create databases (unless existent)
- Create and update design documents
- Integrate couchdb-bootstrap?
Copyright (c) 2017
Licensed under the MIT license.