I am running a couchDB Server with the following map function:
function(doc) {
if (doc.data.appVersion) {
emit([doc.data.appVersion, doc.data.date], doc);
}
}
I can easily query for a appVersion or a range of appVersion by using something like this:
Start key: ["1.2.3", 0] End key: ["2.0.0", 10000000000000]
I can also query for a appVersion between two dates:
Start key: ["1.2.3", 1420066800000] End key: ["1.2.3", 1422572400000]
What I can't do is to get all docs regardless of their appVersion but between two dates. This does not work:
Start key: ["0.0.0", 1420066800000] End key: ["9.9.9", 1422572400000]
The query would also include all docs with an appVersion between 0.0.0 and 9.9.9. The date is completely ignored. It is like:
"get all docs with appVersion between 0.0.0 and 9.9.9 OR date between 1420066800000 and 1422572400000".
But want I want is:
"get all docs with appVersion between 0.0.0 and 9.9.9 AND date between 1420066800000 and 1422572400000"
Is there a way to do all make all three query work? Do I have to change the map-function? How? Or do I have to create another map function just for that last kind of query. I'd like to do this with one map-function because there are more properties I'd like to query for.
I am using couchDB with pouchDB on the client side.