Thanks for your input!

29 jun 2009 kl. 16.53 skrev Zachary Zolton:

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

OK, that worked fine.

2) For 1000 latest docs, use descending=true&limit=1000 in your query URL

But that gives my csv data in reverse order which isn't what I want. I'm feeding a graph generator with time series data and must keep the time un-reversed. :)

 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)?

Bad on my side it seems, was testing with curl and I guess some encoding was wrong. Testing with the app "HTTP Client" (really nice app for mac btw) gives proper result. Now I just have to learn to URI- escape "2009/06/27 11:20" properly. :)

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

It's basically just strings for the moment which the graph generator parses, but I will try better ways of doing it so I keep this in mind.


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