On Thu, Sep 11, 2014 at 3:17 PM, Matthieu Rakotojaona <
[email protected]> wrote:

> Excerpts from Eric B's message of 2014-09-11 16:19:21 +0200:
>
> To be more precise, the map process happens somewhat like that (in
> pseudocode):
>
>     for doc in new_docs():
>       emit some_property from doc
>
> The key here is that CouchDB is targeted towards querying sorted things.
> You have to make it so that property sorts.
>
> For example, for the second example, you should emit the order date in a
> sortable date (use ISO8601). For the first example, on each order, emit
> something like "user_id:order_date" with a sortable order_date. When
> user_id 4 connects and fetches its 5 last ordered items, CouchDB will
> just iterate on the 5 relevant entries that you have indexed.
>

Maybe I misread something in the CouchDB docs, but I thought I could only
sort based on the key - not the value  - of a view.  If I am
emitting user_id : order_date, how would I be able or sort the last 5 items?

I've been trying to read the Definitive Guide to CouchDB (
http://guide.couchdb.org/editions/1) but it seems as though it is quite
old.  It refers to CouchDB v0.10 and I see that CouchDB is already at
v1.6.1.  Is there a better reference guide to learning CouchDB?


Thanks,

Eric

Reply via email to