summaryrefslogtreecommitdiff
path: root/share/www/script/couch.js
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2008-10-05 16:00:15 +0000
committerJohn Christopher Anderson <jchris@apache.org>2008-10-05 16:00:15 +0000
commitcf69d22a07e9c8687dda93c830f5ff01f99be829 (patch)
tree9755172da93b34e574e51b20b62b44b384897c41 /share/www/script/couch.js
parent023179170f616f574fb65db8c5e6bf65cfc5bebf (diff)
added multi-key requests to _view, _temp_view, and _all_docs (with help from davisp)
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@701814 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch.js')
-rw-r--r--share/www/script/couch.js29
1 files changed, 24 insertions, 5 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index cf26bb2e..87bba88a 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -112,8 +112,11 @@ function CouchDB(name) {
}
// Applies the map function to the contents of database and returns the results.
- this.query = function(mapFun, reduceFun, options) {
+ this.query = function(mapFun, reduceFun, options, keys) {
var body = {language: "javascript"};
+ if(keys) {
+ body.keys = keys ;
+ }
if (typeof(mapFun) != "string")
mapFun = mapFun.toSource ? mapFun.toSource() : "(" + mapFun.toString() + ")";
body.map = mapFun;
@@ -132,8 +135,16 @@ function CouchDB(name) {
return result;
}
- this.view = function(viewname, options) {
- var req = request("GET", this.uri + "_view/" + viewname + encodeOptions(options));
+ this.view = function(viewname, options, keys) {
+ var req = null ;
+ if(!keys) {
+ req = request("GET", this.uri + "_view/" + viewname + encodeOptions(options));
+ } else {
+ req = request("POST", this.uri + "_view/" + viewname + encodeOptions(options), {
+ headers: {"Content-Type": "application/json"},
+ body: JSON.stringify({keys:keys})
+ });
+ }
if (req.status == 404)
return null;
var result = JSON.parse(req.responseText);
@@ -151,8 +162,16 @@ function CouchDB(name) {
return result;
}
- this.allDocs = function(options) {
- var req = request("GET", this.uri + "_all_docs" + encodeOptions(options));
+ this.allDocs = function(options,keys) {
+ var req = null;
+ if(!keys) {
+ req = request("GET", this.uri + "_all_docs" + encodeOptions(options));
+ } else {
+ req = request("POST", this.uri + "_all_docs" + encodeOptions(options), {
+ headers: {"Content-Type": "application/json"},
+ body: JSON.stringify({keys:keys})
+ });
+ }
var result = JSON.parse(req.responseText);
if (req.status != 200)
throw result;