Socket
Socket
Sign inDemoInstall

couchdb-mkdb

Package Overview
Dependencies
9
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    couchdb-mkdb

Utility to create couchdb databases easier.


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Install size
129 kB
Created
Weekly downloads
 

Readme

Source

couchdb-mkdb

couchdb-mkdb makes it easy to create databases and stream couchdb's response.

Installation

$ npm i -S couchdb-mkdb

Usage

Express example

This express route creates new databases on every request.

...
app.post('/', (req, res, next) => {
  let name = 'mydb-' + uuid.v1();
  let opts = {

    // `security` is a special option ...
    host: app.get('couchdb'),
    security: {
      admins: {names: [req.user.name], roles: []},
      members: {names: [], roles: []}
    },

    // ... all other options are passed to the underlaying `request` function.
    // See [http.request()](https://nodejs.org/api/http.html#http_http_request_options_callback)
    auth: app.get('auth')
  };

  // Use the mkdb utility to create the database
  mkdb(name, opts)
    .on('error', next)
    .on('errorResponse', function(response) {
      response.pipe(
        res.set(response.headers)
          .status(response.statusCode)
      );
    })
    .on('success', function() {
      res.send({ok: true});
    });
});

API

mkdb(name, [opts], callback)

  • name The name of the database
  • opts Optional options object. See below
  • callback Function with the signature fn(error, response)

Available options are:

  • security The security rules to apply to the database. See Couchdb security

All other options are passed to the underlaying http.request() function.

Events
  • error(err) - Emitted on request error
  • errorResponse(res) - Emitted when couchdb returns a paranormal response
  • success - Emitted on success

Tests

$ git clone https://github.com/domachine/node-couchdb-mkdb.git
$ cd node-couchdb-mkdb
$ npm i
$ npm test

Keywords

FAQs

Last updated on 10 Nov 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc