couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Couchdb Wiki] Update of "Actions" by PaulDavis
Date Wed, 17 Dec 2008 06:47:00 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by PaulDavis:

New page:
Actions are a default included functionality that is made available by the new ExternalProcess
feature. ''_design/'' docs can now specify an ''actions'' member that is an object of ''key''/''function''

Action functions are specified in JavaScript and have access to a CouchDB object that can
make requests to the database.

== Example ''_design/'' Document ==

    "_id": "_design/an_action",
    "actions": {
        "times_two": "function(req, db) {return {code:200, json: {val: req.query.q * 2}};}"

By default, this action is available at the URL:


== Example Using the Database ==

The ''db'' argument is a CouchDB instance. This class is defined in ''couch.js'' at:


For now the best references on the API are couch.js itself, and couch_tests.js that exercises
it and most of CouchDB.

    _id: "_design/with_db",
    actions: {
        "get" : "function(req, db) { var doc =; return {json:doc}

Accessed via:


== Caveats ==

The actions functionality is still a bit rough around the edges and there are efficiency questions
on the implementation. Also, the error reporting is sub-par (to say the least...).

That said, it helps serve as a reference (and testable) example of _external.

View raw message