I have 5680 documents in my CouchDB.
I reduced it with something like:
function(doc) {
if (doc.address.country && doc.cats) {
for (i = 0; i < doc.cats.length; i++) {
emit([doc.address.country, doc.cats[i].id], doc);
}
}
}
Running my view with: myview?key=["CC","category"]
Returns the expected result (25 items).
However there is a field in the response:
{"total_rows":5680,"offset":5655, ...
The total_rows count is my full data set, not only the ones which matched my query. Is there a way to see the matching rows in the result?
I would like to prevent duplicating the map code to just add a reduce function. In addition I would like to prevent two http requests just for that information.
For me this information would be useful to implement something like pagination.
I have read this: http://docs.couchdb.org/en/1.6.1/couchapp/views/pagination.html
But they are not paginating over a limited subset of my data rows.
As I found out, simply substracting offset from the total rows will not work (of course).
How can I have a correct number of total_rows in my response, or what are the best practices in my use case?
Thanks!