A few comments:

  1) You shouldn't have to emit the doc, as the value in your map.
Instead try include_doc=true in your URL
  2) For 1000 latest docs, use descending=true&limit=1000 in your query URL
  3) What's "not working" about the startkey/endkey range? You mean,
no docs come back? Do they come back correctly in your view (without
the list)?

Make sure your dates get serialized into JSON the way you intended...

On Mon, Jun 29, 2009 at 8:47 AM, Per Ejeklint<[email protected]> wrote:
> I'm stuck with a really basic, stupid question about a couchapp running in
> 0.10. If I have data containing this
>
> {
>   "_id": "559884160",
>   "_rev": "1-90616862",
>   "timestamp": "2009/06/27 12:00",
>   "doctype": "readings",
>   "temp_outdoor": 21.6,
> ...
> }
>
> and a map function by_date like this:
>
> function(doc) {
>        if (doc.doctype == "readings") {
>                emit(doc.timestamp, doc);
>        }
> }
>
>
> and list function like this (simplified) producing csv data:
>
> function(head, req) {
>  start({headers: { 'Content-Type': 'text/csv; charset=utf-8' }, body: ''});
>
>  var row;
>  while (row = getRow()) {
>        var doc = row.value;
>    if (doc.timestamp && doc.temp_outdoor) {
>      send(doc.timestamp + ';' + doc.temp_outdoor + '\n');
>    }
>  }
> };
>
> how on earth do I use startkey/endkey when calling? Like this doesn't work:
>
> curl -vX GET ....mycouchapp.../_list/data/by-date?startkey="2009/06/29
> 13:43"&endkey="2009/06/29 14:43"
>
> Have tried all sorts of escaping and stuff but can't figure it out.
> Apparently I'm blind to something. Any hints?
>
> Also, if I want to just get the latest 1000 docs, what would the call look
> like?
>
> Lost in newbie space...
>
> /Per
>

Reply via email to