summaryrefslogtreecommitdiff
path: root/share/www/script/couch.js
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-05-15 21:51:22 +0000
committerDamien F. Katz <damien@apache.org>2008-05-15 21:51:22 +0000
commita684f95cbcee7f2568a2ce04e7dc2bbb605a27b3 (patch)
tree3b2fafecde418e10834ec2e896efffb64b16a33a /share/www/script/couch.js
parent41eeac05bff1b0a8b05f1110270c0beecd62991a (diff)
Incremental reduce first checkin. Warning! Disk format change.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@656861 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch.js')
-rw-r--r--share/www/script/couch.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index 5f42ac38..f72fb712 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -99,7 +99,23 @@ function CouchDB(name) {
mapFun = mapFun.toSource ? mapFun.toSource() : "(" + mapFun.toString() + ")";
var req = request("POST", this.uri + "_temp_view" + encodeOptions(options), {
headers: {"Content-Type": "text/javascript"},
- body: mapFun
+ body: JSON.stringify(mapFun)
+ });
+ var result = JSON.parse(req.responseText);
+ if (req.status != 200)
+ throw result;
+ return result;
+ }
+
+ // Applies the map function to the contents of database and returns the results.
+ this.reduce_query = function(mapFun, reduceFun, options) {
+ if (typeof(mapFun) != "string")
+ mapFun = mapFun.toSource ? mapFun.toSource() : "(" + mapFun.toString() + ")";
+ if (typeof(reduceFun) != "string")
+ reduceFun = reduceFun.toSource ? reduceFun.toSource() : "(" + reduceFun.toString() + ")";
+ var req = request("POST", this.uri + "_temp_view" + encodeOptions(options), {
+ headers: {"Content-Type": "text/javascript"},
+ body: JSON.stringify({map:mapFun, reduce:reduceFun})
});
var result = JSON.parse(req.responseText);
if (req.status != 200)