Reputation: 961
I want a query in pouchDB which returns me all entries where property x is between 1 and 5 AND where property z equals 'test'.
I wrote a query which returns me all entries between 1 and 5 but I have no idea how I can extend my query to also consider the equals condition.
var options = {
include_docs: true,
startkey: [1],
endkey: [5]
};
var query = function (entry) {
emit([entry.x]);
};
database.query(query, options)
.then(function (result) { /* ... */ })
.catch(function (err) { /* ... */ });
Upvotes: 0
Views: 829
Reputation: 818
You could emit the key as:
emit([entry.z, entry.x]);
and then search:
http://.......view?startkey=["test",1]&endkey=["test",5]
Bear in mind that you cannot execute a query with both parts of the key being constrained by a range. Here is some documentation on searching: http://guide.couchdb.org/draft/views.html
Upvotes: 1