Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.


  1. Outdated egg!
  2. couchdb-view-server
    1. Description
    2. Deprecation Notice
    3. Author
    4. Requirements
    5. Documentation
      1. emit
      2. ref
      3. log
    6. Example


Implements a Scheme view server for Apache CouchDB.

Deprecation Notice

This egg is no longer maintained and is known not to work with recent Chicken versions (at least since 4.8.x). Please get in touch with the author if you want to adopt maintenance.


Moritz Heidkamp


Requires the environments and json eggs. Also, for it to be somewhat useful, you need a CouchDB server with the following setting in the [query_servers] config section:

  scheme = /usr/bin/chicken-couchdb

The path to chicken-couchdb may be different on your system, of course.

You can now use "scheme" as a view language.


Within your map and reduce definitions, you have access to all R5RS procedures as well as those from SRFI-1. There is a binding for null which contains the result of (void) i.e. #<unspecified> and can be used to generate JSON nulls. The following procedures are also available:


[procedure] (emit key value)

Just like in the default JavaScript view server, emit is implicitly available and is used to emit results from the map function.


[procedure] (ref key doc)

Allows accessing values in avectors by key (json uses these to represent JSON objects).


(ref 'foo '#((foo . bar)))
=> bar


[procedure] (log message)

Can be used to make the CouchDB server log a message.


   "_id": "_design/foo",
   "_rev": "1-8e9036611c14d4ffe34e9065a3a33683",
   "language": "scheme",
   "views": {
       "by-created-at": {
           "map": "(lambda (doc) (let ((title (ref 'title doc)))
				   (if title (begin
					       (log (string-append \"mapping \" title))
					       (emit null (ref 'created-at doc))))))",
           "reduce": "(lambda (k v r) (fold + 0 v))"