couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthieu Rakotojaona <matthieu.rakotoja...@gmail.com>
Subject Re: Latest Items in Categories
Date Wed, 23 May 2012 19:03:39 GMT
On Wed, May 23, 2012 at 5:40 PM, Zdravko Gligic <zgligic@gmail.com> wrote:
> However, on the menu itself, beside each category I would like to list
> last 5 videos or articles that have been posted into that category.

You ccould add a "date_added" field to each of your doc, and use a
view that emits the category along with the date_added. You can now
query for the category, sort by date_added, and pick only the 5 first
(or last, using a reverse ordering).

The problem I see with that approach is that you will store a lot of
information (in fact, some information for _every_ document in your
database) just to display the 5 last. In the long run, I think that
the idea of a process watching the _changes feed might be a good
aproach ...

-- 
Matthieu RAKOTOJAONA

Mime
View raw message