0.0.9 • Published 8 years ago

view-builder v0.0.9

Weekly downloads
12
License
BSD
Repository
github
Last release
8 years ago

view-builder

A node utility to create and update couchdb views

Installation

npm install -g view-builder

Usage

Command Line (Update)

Updates the views found in the specified database from the specified definitions

view-builder --url http://localhost:5984/databasename --defs ./path/to/views.js

If omitted, the defs parameter will default to a file named views.js in the current folder.

This relies on views.js containing something like the following:

exports.designDocumentName = {
    views: {
        viewName: {
            map: function () { }
        }
    },
    filters: {
        filter1: function() {}
    }
};

The config file can contain multiple design documents, each of which can contain multiple views and filters.

Updating Existing documents

To avoid accidental rebuilds of entire views, view-builder will not automatically overwrite an existing design document (see #1). If this behaviour is required then you can use the force flag:

view-builder --url http://... --force

Command Line (Generate)

Generates a view definition file based on the views already in the database

view-builder --url http://localhost:5984/databasename --defs ./path/to/views.js --generate

If omitted, the defs parameter will default to a file named views.js in the current folder.

require

var builder = require("view-builder");
builder("http://localhost:5984/databasename", "./path/to/views.js");
// or...
builder("http://localhost:5984/databasename", {
    designDocumentName = {
        views: {
            viewName: {
                map: function () { }
            }
        },
        filters: {
            filter1: function() {}
        }
    }
});

As in the command line example, the second parameter will default to a file named views.js in the current folder.

0.0.9

8 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago