couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Hillenbrand <joehil...@gmail.com>
Subject View based on date/time?
Date Fri, 22 Apr 2011 21:21:43 GMT
I'm trying to write a view that only shows documents that are less than an
hour old.

My map function looks like this:

function (doc){
        var now = new Date().getTime();
        var age = now - Date.parse(doc.date);
        if (age < 1*1000*60*60){
            emit(doc._id, doc.parent);
        }
}

This code works in the browser. But when I run it as a view I get no
results.

I'm guessing that CouchDB's javascript library doesn't have a Date() object.
Now would I find that out? I can't seem to find any documentation for what
CouchDB's javascript does and does not have.

Also, I don't seem to have any way to debug view functions, for finding
errors such as forgetting a semi-colon or finding out that there is no
Date().

I'm running CouchDB 1.0.1

Thanks,

-Joe

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