(type egg)
(signature "couchdb-view-server egg")
(timestamp 1612269487)
(sxml ((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/couchdb-view-server" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg")) (section 2 "couchdb-view-server" (toc) (section 3 "Description" (p "Implements a Scheme " (link "http://wiki.apache.org/couchdb/View_server" "view server") " for " (link "http://bcouchdb.apache.org/" "Apache CouchDB") ".")) (section 3 "Deprecation Notice" (p "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.")) (section 3 "Author" (p (int-link "/users/moritz-heidkamp" "Moritz Heidkamp"))) (section 3 "Requirements" (p "Requires the " (int-link "environments") " and " (int-link "json") " eggs. Also, for it to be somewhat useful, you need a CouchDB server with the following setting in the " (tt "[query_servers]") " config section:") (highlight scheme "  scheme = /usr/bin/chicken-couchdb") (p "The path to " (tt "chicken-couchdb") " may be different on your system, of course.") (p "You can now use " (tt "\"scheme\"") " as a view language.")) (section 3 "Documentation" (p "Within your " (tt "map") " and " (tt "reduce") " definitions, you have access to all R5RS procedures as well as those from SRFI-1. There is a binding for " (tt "null") " which contains the result of " (tt "(void)") " i.e. " (tt "#<unspecified>") " and can be used to generate JSON " (tt "null") "s. The following procedures are also available:") (section 4 "emit" (def (sig (procedure "(emit key value)" (id emit))) (p "Just like in the default JavaScript view server, " (tt "emit") " is implicitly available and is used to emit results from the " (tt "map") " function."))) (section 4 "ref" (def (sig (procedure "(ref key doc)" (id ref))) (p "Allows accessing values in avectors by key (" (int-link "json") " uses these to represent JSON objects).") (p "Example:") (highlight scheme "(ref 'foo '#((foo . bar)))\n=> bar"))) (section 4 "log" (def (sig (procedure "(log message)" (id log))) (p "Can be used to make the  CouchDB server log a message.")))) (section 3 "Example" (highlight javascript "{\n   \"_id\": \"_design/foo\",\n   \"_rev\": \"1-8e9036611c14d4ffe34e9065a3a33683\",\n   \"language\": \"scheme\",\n   \"views\": {\n       \"by-created-at\": {\n           \"map\": \"(lambda (doc) (let ((title (ref 'title doc)))\n\t\t\t\t   (if title (begin\n\t\t\t\t\t       (log (string-append \\\"mapping \\\" title))\n\t\t\t\t\t       (emit null (ref 'created-at doc))))))\",\n           \"reduce\": \"(lambda (k v r) (fold + 0 v))\"\n       }\n   }\n}")))))
