couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Ramage <ryan.ram...@gmail.com>
Subject Re: how to fetch the newes document of every type?
Date Fri, 26 Oct 2012 21:07:18 GMT
function map(doc) {
    emit(['all', doc.created], doc.headline)
    emit([doc.news_type, doc.created], doc.headline)
}

ddoc/_view/by_type?start_key=["world",{}]&end_key=["world"]&descending=true&limit=20
ddoc/_view/by_type?start_key=["all",{}]&end_key=["all"]&descending=true&limit=20



On Fri, Oct 26, 2012 at 3:01 PM, Dirk Heilig <dirk@heilig-online.com> wrote:
> i've already thought about that, bis in my example, ill might get the result:
>
> world-news from yesterday
> world-news from 2 days ago
> sports-news from last weekend
>
>
> but i want exacly one of a kind, not the last 3 once
>
> 2012/10/26 Jens Alfke <jens@couchbase.com>:
>>
>> On Oct 26, 2012, at 12:48 PM, Dirk Heilig <dirk@heilig-online.com> wrote:
>>
>>> what i need is a view, and the magic wat to query this view to get the
>>> lastest news of any kind, how do i manage this?
>>
>> Emit the ‘created’ property as the key. Then query the view in descending order
with a limit.
>>
>> —Jens

Mime
View raw message