couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars <la...@systemli.org>
Subject Re: CouchDB: Most recently added document that is NOT a design document
Date Tue, 07 Jan 2014 00:16:10 GMT
It might depend on your definition of "added document". If `PUT
/db/docid` and `POST /db` are the only ways to "add", then do what Bob
said and stop at the first non-design document with a seq number of 1.
It starts getting tricky if you also include in your definition
documents that are created by replication, and I'm not sure how to
handle that.

On 07.01.2014 01:01, Robert Newson wrote:
> 
> read _changes?descending=true row by row until you reach a non-design document? The doc
to ddoc ratio should be strongly in your favor.
> 
> B.
> 
> On 6 Jan 2014, at 22:00, Stanley Iriele <siriele2x3@gmail.com> wrote:
> 
>> Could you do what Jens just mentioned and just make a filter?....that way a
>> seq number plus the filter should get you what you want
>> On Jan 6, 2014 1:28 PM, "Jens Alfke" <jens@couchbase.com> wrote:
>>
>>>
>>> On Jan 6, 2014, at 12:42 PM, Hank Knight <hknight555@gmail.com> wrote:
>>>
>>>> I want the ID of the most recently added document that is NOT a design
>>>> document.
>>>
>>> There’s nothing built-in for that. CouchDB doesn’t track the order in
>>> which documents are created, only the order in which they’re changed.
>>>
>>> You could put a “date_created” property in a document and populate it with
>>> a timestamp when the doc is first created; then you can make a view that
>>> emits those as keys, and query it in reverse order.
>>>
>>> —Jens
> 

Mime
View raw message