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 2017/07/04 12:14:14 UTC
[couchdb-nano] 01/01: feat: add _find
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch feat/find
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
commit 421e0fab0cd91c7aacec67020ca8a95a20887305
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Jul 4 14:12:34 2017 +0200
feat: add _find
---
lib/nano.js | 10 ++++++++++
tests/helpers/unit.js | 2 --
tests/integration/database/replicator.js | 10 +++++-----
tests/unit/design/find.js | 31 +++++++++++++++++++++++++++++++
4 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/lib/nano.js b/lib/nano.js
index 86ceba8..5610a60 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -752,6 +752,15 @@ module.exports = exports = nano = function dbScope(cfg) {
}, callback);
}
+ function find (selector, callback) {
+ return relax({
+ db: dbName,
+ path: '_find',
+ method: 'POST',
+ body: selector
+ }, callback);
+ }
+
// db level exports
docScope = {
info: function(cb) {
@@ -796,6 +805,7 @@ module.exports = exports = nano = function dbScope(cfg) {
search: viewSearch,
spatial: viewSpatial,
view: viewDocs,
+ find: find,
viewWithList: viewWithList,
server: serverScope,
replication: {
diff --git a/tests/helpers/unit.js b/tests/helpers/unit.js
index bf9f21a..52cd7e6 100644
--- a/tests/helpers/unit.js
+++ b/tests/helpers/unit.js
@@ -93,7 +93,6 @@ helpers.unit = function(method, error) {
assert.deepEqual(req, stub);
assert.end();
});
-
f.apply(null, args);
});
};
@@ -109,7 +108,6 @@ function mockClient(code, path, extra) {
if(error) {
return cb(error);
}
-
if(code === 500) {
cb(new Error('omg connection failed'));
} else {
diff --git a/tests/integration/database/replicator.js b/tests/integration/database/replicator.js
index be77071..a5f8e15 100644
--- a/tests/integration/database/replicator.js
+++ b/tests/integration/database/replicator.js
@@ -52,10 +52,10 @@ it('should be able to replicate (replicator) three docs', function(assert) {
assert.true(disabled, 'should not be null');
assert.true(disabled.ok, 'should have stopped the replication');
assert.end();
- });
+ });
})
})
- },
+ },
3000)
};
waitForReplication();
@@ -84,7 +84,7 @@ it('should be able to replicate (replicator) to a `nano` object', function(asser
});
});
})
- },
+ },
3000)
};
waitForReplication();
@@ -111,9 +111,9 @@ it('should be able to replicate (replicator) with params', function(assert) {
assert.true(disabled.ok, 'should have stopped the replication');
assert.end();
});
- });
+ });
})
- },
+ },
3000)
};
waitForReplication();
diff --git a/tests/unit/design/find.js b/tests/unit/design/find.js
new file mode 100644
index 0000000..32d9964
--- /dev/null
+++ b/tests/unit/design/find.js
@@ -0,0 +1,31 @@
+// Licensed under the Apache License, Version 2.0 (the 'License'); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+'use strict';
+var findDesign = require('../../helpers/unit').unit([
+ 'find',
+ 'find'
+]);
+
+findDesign({
+ selector: {
+ name: 'foobar'
+ }
+}, {
+ body: '{"selector":{"name":"foobar"}}',
+ headers: {
+ accept: 'application/json',
+ 'content-type': 'application/json'
+ },
+ method: 'POST',
+ uri: '/mock/_design/mango/_view/banana'
+});
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.