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.
couchdb-view-server
TOC »
Description
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.
Author
Requirements
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.
Documentation
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:
emit
- emit key valueprocedure
Just like in the default JavaScript view server, emit is implicitly available and is used to emit results from the map function.
ref
- ref key docprocedure
Allows accessing values in avectors by key (json uses these to represent JSON objects).
Example:
(ref 'foo '#((foo . bar))) => bar
log
- log messageprocedure
Can be used to make the CouchDB server log a message.
Example
{ "_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))" } } }