safe-couch-design-doc-upserter
CouchDB design document upserter tool extended by API
Last updated 2 years ago by akosbalasko .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install safe-couch-design-doc-upserter 
SYNC missed versions from official npm registry.

couchupsert

A tool to assist for inserting or updating CouchDB Design Documnents. It provides a command line and API interfaces as well in order to use it manually, or automatically from your application or CI tools.

Installation

npm install -g safe-couch-design-doc-upserter

Usage

Create a JSON file with your design document in e.g. dd.json

{
    "_id": "_design/fetch",
    "views": {
        "byx": {
            "map": "function (doc) {\n  emit(doc.x, doc.y);\n  }\n}",
            "reduce": "_stats"
        }
    },
    "language": "javascript"
}

or a JavaScript file that exports a design document object e.g.

var map = function(doc) {
  emit(doc.name, null);
};


module.exports = {
  _id: "_design/testy",
  views: {
    test1: {
      map: map.toString(),
      reduce: "_count"
    }
  }
};

Then setup environment variables to point to your instance of CouchDB

export COUCH_URL=http://127.0.0.1:5984

or

export COUCH_URL=https://myusername:mypassword@myhost.cloudant.com

Then run couchupsert:

couchupsert --dd dd.json --db mydatabase
  • dd - the path to the file containing the design documnet
  • db - the name of the database

(if the file extension of dd is '.json', it is expected to be a JSON document, if it ends in '.js' it is expected to be a JavaScript file that can be required in)

If the design document is already present and is identical to the one in the file, no migration will occur, otherwise

  • copy old design document to _OLD
  • import new design document to _NEW
  • trigger the view to make sure it builds
  • poll the view to see if it has finished building
  • copy _NEW to the real design document name
  • delete _NEW
  • delete _OLD
  • exit

In other words, couchmigrate will only return when the design document has been uploaded, built and has been moved into place.

Current Tags

  • 0.9.0                                ...           latest (2 years ago)

7 Versions

  • 0.9.0                                ...           2 years ago
  • 0.7.5 [deprecated]           ...           2 years ago
  • 0.7.4 [deprecated]           ...           2 years ago
  • 0.7.3 [deprecated]           ...           2 years ago
  • 0.7.2 [deprecated]           ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 10
Dependencies (10)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |