couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulises <ulises.cerv...@gmail.com>
Subject Re: View with incremental counter
Date Tue, 18 Nov 2008 13:02:01 GMT
That's what I thought. The output is definitely sorted by key, but the
> document with a 'count' of one is in the middle of my results.
>
> I just tried this view for debugging:
>
> count = 0;
> function(doc) {
>  if(doc.type == "document") {
>    count = count + 1
>     emit(doc._id, [count, doc.updated_at]);
>  }
> }
>
> and it turns out that the document with a count of 1 is the most
> recently updated document.
>

But isn't the signature of the emit fn emit(key, value)? Wouldn't it make
more sense then to emit([doc._id, count], some_value) however even then it'd
end up sorted only by doc._id. Perhaps emit([count, doc._id], some_value)
would do the trick.

U

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message