incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail A. Pokidko" <mikhail.poki...@gmail.com>
Subject searching for something like AND clause
Date Thu, 02 Sep 2010 10:06:46 GMT
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

Mime
View raw message