Hello all!

I have docs with such fields : {'type':'offer', 'city':''Moscow',
'expires':'2010/08/30 22:54:00',}
And now i`m stuck finding the way how to get unexpired offers for certain city.

My first attempt was writing view like this:
function(doc) {
    var today = new Date();
    if (doc.type == 'offer') {
        var created = new Date(doc.expiration_full);
        if (created > today) {
                emit(doc.city, doc);
        }
    }
}

But "today" stays as defined at the moment of view save. (Yes, i
understand that other way indexes should be recalculated every time)

So is there any clever way to get unexpired offers for certain city
without writing view-per-city?startkey=%{today_date} ?

-- 
xmpp: pma AT altlinux DOT org

Reply via email to