Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
CouchDB database and document setup tool
JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
examples
lib
test
.gitignore
CHANGELOG.md
LICENSE
README.md
package.json

README.md

Couchpenter http://travis-ci.org/cliffano/couchpenter

Couchpenter is CouchDB database and document setup tool.

Installation

npm install -g couchpenter 

Usage

Create setup file example:

couchpenter init

Execute a command against a CouchDB URL with specific Couchpenter configuration file:

couchpenter <target> -u http://user:pass@localhost:5984 -f couchpenter.json

Targets:

setup Create databases, then create/update documents.
teardown Delete databases.
setup-db Create databases only.
setup-doc Create documents only.
teardown-db Like teardown, delete databases.
teardown-doc Delete documents only.

Programmatically:

var couchpenter = new require('couchpenter').Couchpenter(
  'http://user:pass@localhost:5984',
  'couchpenter.json',
  process.cwd()
);
couchpenter.setUp(function (err) {
  // handle error
});

Configuration

Couchpenter setup file is a just a simple JSON file containing:

{
  "db1": [
    { "_id": "doc1", "foo": "bar" },
    { "_id": "doc2", "foo": "bar" },
    "path/to/doc3file.json"
  ],
  "db2": [
    { "_id": "doc4", "foo": "bar" },
    "path/to/modulename"
  ],
  "db3": [],
  "_replicator": {
    {
      "_id": "db1_pull",
      "source": "http://user:pass@remotehost:5984/db1",
      "target": "db1",
      "user_ctx": {
        "name": "user",
        "roles": ["_admin"]
      },
      "continuous": true,
      "max_replication_retry_count": "infinity"
    }
  }
}

Property keys are the names of the databases that should exist in CouchDB. If a database does not exist, it will then be created.

Property values are the documents that should exist in each database. If the document does not exist, it will then be created. If it already exists, it will then be updated.

A document can be represented as:

  • an object
  • a file path string containing a JSON document, file name must end with .json
  • a module path string

Paths are relative to current directory if it's used from command-line, or relative to setUp's dir (process.cwd() in the usage example further above) if it's used programmatically.

Colophon

Follow @cliffano on Twitter.

Something went wrong with that request. Please try again.