couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [6/6] couchdb-nano git commit: Encode search parameters which must be JSON-encoded
Date Fri, 04 Dec 2015 09:16:59 GMT
Encode search parameters which must be JSON-encoded


Project: http://git-wip-us.apache.org/repos/asf/couchdb-nano/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-nano/commit/c03b5528
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-nano/tree/c03b5528
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-nano/diff/c03b5528

Branch: refs/heads/master
Commit: c03b5528b6b0759f7e001b722199f824163ad3a0
Parents: a5b787c
Author: Jason Smith <jason.h.smith@gmail.com>
Authored: Thu Oct 22 13:40:05 2015 +0700
Committer: Jason Smith <jason.h.smith@gmail.com>
Committed: Thu Oct 22 13:40:05 2015 +0700

----------------------------------------------------------------------
 lib/nano.js | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-nano/blob/c03b5528/lib/nano.js
----------------------------------------------------------------------
diff --git a/lib/nano.js b/lib/nano.js
index 0cd0bc4..9ca5137 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -499,6 +499,15 @@ module.exports = exports = nano = function dbScope(cfg) {
 
       var viewPath = '_design/' + ddoc + '/_' + meta.type + '/'  + viewName;
 
+      // Several search parameters must be JSON-encoded; but since this is an
+      // object API, several parameters need JSON endoding.
+      var paramsToEncode = ['counts', 'drilldown', 'group_sort', 'ranges', 'sort'];
+      paramsToEncode.forEach(function(param) {
+        if (param in qs) {
+          qs[param] = JSON.stringify(qs[param]);
+        }
+      });
+
       if (qs && qs.keys) {
         var body = {keys: qs.keys};
         delete qs.keys;


Mime
View raw message