How would I execute a query equivalent to "select top 10" in couch db?
For example I have a "schema" like so:
title body modified
and I want to select the last 10 modified documents.
As an added bonus if anyone can come up with a way to do the same only per category. So for:
title category body modified
return a list of latest 10 documents in each category.
I am just wondering if such a query is possible in couchdb.
here is what you need to do.
Map function
then you need a list function that groups them, you might be temped to abuse a reduce and do this, but it will probably throw errors because of not reducing fast enough with large sets of data.
you can get all categories top 10 now with
and get the docs with
now you can query this with a multiple range POST and limit which categories
you could also not hard code the
10
and pass the number in through thereq
variable.Here is some more View/List trickery.