incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail A. Pokidko" <>
Subject Re: searching for something like AND clause
Date Thu, 02 Sep 2010 10:32:45 GMT
On Thu, Sep 2, 2010 at 2:18 PM, Wout Mertens <> wrote:
> Hi Mikhail,
> you should write your views so they do not change.

Yeah, finally i undestood this ehan found out that Date() inside view
have showd unpected results))

> For the expiring dates, that means you need to make the expiration date a key and then
you can query all entries that expire later than a given date.
> function(doc) {
>   doc.type == 'offer' && emit (doc.expires,doc);
> }

Unfortunately simple view that returns unexpired offers is not enough

> Since you want to filter on city AND date, you can do
> function(doc) {
>   doc.type == 'offer' && emit ([,doc.expires],doc);
> }
> and then you can get all offers for a certain city by querying with startkey ["Moscow",Date()]
> Functions are untested and I'm a little rusty in Javascript so they may be wrong but
you get the idea :)

I`ve tried such combinations - version with emit([,
doc.expires],doc) i find a little bit clumsy :
- it would be difficult to wrap with rewrites to something like, i mean date-key, not city-key.

So i thought there may be more elegant way.

xmpp: pma AT altlinux DOT org

View raw message