You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/07/24 19:53:26 UTC

[couchdb-nano] branch deps/linters updated (f18a4f7 -> 1c20308)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch deps/linters
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git.


    from f18a4f7  drop jshint dep
     add f5d9cb7  Added support for multiple view queries
     add e75d71e  Add tests for PR #56 (support multiple query view)
     add a57c91b  Fix merge conflicts for #80
     add bdb1cd0  Merge pull request #80 from adamsaeid/multi-view-queries
     new 1c20308  Merge branch 'master' into deps/linters

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 lib/nano.js                       | 10 ++++++++++
 tests/fixtures/design/query.json  |  5 +++++
 tests/integration/design/query.js | 33 +++++++++++++++++++++++++++++++++
 tests/unit/design/view.js         | 17 +++++++++++++++++
 4 files changed, 65 insertions(+)


[couchdb-nano] 01/01: Merge branch 'master' into deps/linters

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch deps/linters
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git

commit 1c2030858aa17383303d17fb4f8e20f67fc52d06
Merge: f18a4f7 bdb1cd0
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Jul 24 21:53:24 2018 +0200

    Merge branch 'master' into deps/linters

 lib/nano.js                       | 10 ++++++++++
 tests/fixtures/design/query.json  |  5 +++++
 tests/integration/design/query.js | 33 +++++++++++++++++++++++++++++++++
 tests/unit/design/view.js         | 17 +++++++++++++++++
 4 files changed, 65 insertions(+)

diff --cc lib/nano.js
index 6dd6aa1,e573888..d9b94bf
--- a/lib/nano.js
+++ b/lib/nano.js
@@@ -617,7 -627,17 +617,17 @@@ module.exports = exports = function dbS
            qs: qs1,
            body: body,
            stream: meta.stream
 -        }, callback);
 +        }, callback)
+       } else if (qs && qs.queries) {
 -        body = {queries: qs.queries};
 -        delete qs.queries;
++        body = {queries: qs.queries}
++        delete qs.queries
+         return relax({
+           db: dbName,
+           path: viewPath,
+           method: 'POST',
+           qs: qs,
+           body: body
 -        }, callback);
++        }, callback)
        } else {
          const req = {
            db: dbName,
diff --cc tests/integration/design/query.js
index 1029af0,7f95ec1..4c477fc
--- a/tests/integration/design/query.js
+++ b/tests/integration/design/query.js
@@@ -10,32 -10,65 +10,65 @@@
  // License for the specific language governing permissions and limitations under
  // the License.
  
 -'use strict';
 +'use strict'
  
 -const async = require('async');
 -const helpers = require('../../helpers/integration');
 -const harness = helpers.harness(__filename);
 -const it = harness.it;
 -const db = harness.locals.db;
 -const viewDerek = helpers.viewDerek;
 +const async = require('async')
 +const helpers = require('../../helpers/integration')
 +const harness = helpers.harness(__filename)
 +const it = harness.it
 +const db = harness.locals.db
 +const viewDerek = helpers.viewDerek
  
 -const opts = {key: ['Derek', 'San Francisco']};
 +const opts = {key: ['Derek', 'San Francisco']}
  
 -it('should create a ddoc and insert some docs', helpers.prepareAView);
 +it('should create a ddoc and insert some docs', helpers.prepareAView)
  
 -it('should respond with derek when asked for derek', function(assert) {
 -  viewDerek(db, assert, opts, assert.end);
 -});
 +it('should respond with derek when asked for derek', function (assert) {
 +  viewDerek(db, assert, opts, assert.end)
 +})
  
 -it('should have no cloning issues when doing queries', function(assert) {
 +it('should have no cloning issues when doing queries', function (assert) {
    async.waterfall([
 -    function(next) { viewDerek(db, assert, opts, next); },
 -    function(next) { viewDerek(db, assert, opts, next); }
 -  ], function(err) {
 -    assert.equal(err, null, 'no errors');
 -    assert.ok(Array.isArray(opts.key));
 -    assert.equal(opts.key[0], 'Derek');
 -    assert.equal(opts.key[1], 'San Francisco');
 -    assert.end();
 -  });
 -});
 +    function (next) { viewDerek(db, assert, opts, next) },
 +    function (next) { viewDerek(db, assert, opts, next) }
 +  ], function (err) {
 +    assert.equal(err, null, 'no errors')
 +    assert.ok(Array.isArray(opts.key))
 +    assert.equal(opts.key[0], 'Derek')
 +    assert.equal(opts.key[1], 'San Francisco')
 +    assert.end()
 +  })
 +})
+ 
+ var multipleQueryOpts = {
+   queries: [
+     {
+       keys: [
+         ['Derek','San Francisco'],
+         ['Nuno','London']
+       ]
+     }, 
+     {
+       skip: 2,
+       limit: 1
+     }
+   ]
+ }
+ 
+ var expectedResults = 
+   [
+     {total_rows:3,offset:0,rows:[{id:"p_derek",key:["Derek","San Francisco"],value:"p_derek"},{id:"p_nuno",key:["Nuno","London"],value:"p_nuno"}]},
+     {total_rows:3,offset:2,rows:[{id:"p_randall",key:["Randall","San Francisco"],value:"p_randall"}]}
+   ]
+ 
+ 
+ it('should support multiple view queries', function(assert) {
+   db.view('people','by_name_and_city', multipleQueryOpts, function(error, response) {
 -    assert.equal(error, null, 'no errors');
++    assert.equal(error, null, 'no errors')
+     assert.ok(response.results, 'should return query results')
 -    assert.ok(Array.isArray(response.results), 'query results should be array');
++    assert.ok(Array.isArray(response.results), 'query results should be array')
+     assert.equal(response.results.length, 2, 'should return results to both queries')
+     assert.deepEqual(response.results, expectedResults, 'should be expected query results')
+     assert.end()
 -  });
 -});
++  })
++})
diff --cc tests/unit/design/view.js
index da40d79,060a1ef..2888e36
--- a/tests/unit/design/view.js
+++ b/tests/unit/design/view.js
@@@ -31,4 -31,20 +31,21 @@@ viewDesign('alice', 'by_id', 
      'include_docs': true
    },
    uri: '/mock/_design/alice/_view/by_id'
 -});
 +})
++
+ 
+ viewDesign('alice', 'by_id', {
+   queries: [{ keys: ['foobar', 'barfoo']}, { limit: 3, skip: 2 }],
+   include_docs: true
+ }, {
+   body: '{"queries":[{"keys":["foobar","barfoo"]},{"limit":3,"skip":2}]}',
+   headers: {
+     accept: 'application/json',
+     'content-type': 'application/json'
+   },
+   method: 'POST',
+   qs: {
+     'include_docs': true
+   },
+   uri: '/mock/_design/alice/_view/by_id'
 -});
++})