Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couchdb-utils

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-utils

CouchDB utils

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

couchdb-utils

Installation

To install via NPM type the following: npm install couchdb-utils

You can also install via git by cloning: git clone https://github.com/paseek/couchdb-utils.git /path/to/your/dir

Usage

Create a database if it doesn't exist:

var cradle = require('cradle'),
    cutils = require('couchdb-utils');

var db = new (cradle.Connection)().database('my-db');

db.createIfNotExists(function(err, existed) {
    if (!err && !existed) console.log('The database has been successfully created.');
});

Manage versioning and updates of couchdb design documents: (based on grave project).

var cradle = require('cradle'),
    cutils = require('couchdb-utils');

var db = new (cradle.Connection)().database('my-database');
var design = new cutils.Design(db, 'my-view', '0.0.2');

design.view('all', {
    map : function (doc) {
        if (doc.type === 'my-doc') emit(doc._id, 1);
    }
});

design.end(function(err) {
    console.log('all views are up-to-date');
});

Design views, lists and updates

new Design(db, name, version)

Create a design with a name and a version. db is an instance of cradle.Database. Theversion should be understood by semver.

var cradle = require('cradle'),
    cutils = require('couchdb-utils');

var db = new (cradle.Connection)().database('my-database');
var design = new cutils.Design(db, 'my-view', '0.0.2');

design.view(name, view)

Define a couchdb view. CouchDB views have map, reduce, and fields of that sort.

design.view('all', {
    map : function (doc) {
        if (doc.type === 'my-doc') emit(doc._id, 1);
    }
});

design.list(name, list)

Define a couchdb list. CouchDB lists are functions that look like function (head, req) { /* ... */ }.

design.update(name, update)

Define a couchdb update. These look like function (doc, req) { /* ... */ }.

design.end(callback)

Declare the end of the design document definitions and save them to couchdb when the design version is greater than the couchdb version.

design.end(function(err) {
    console.log('all views are up-to-date');
});

Keywords

FAQs

Package last updated on 12 May 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc