couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matteo Caprari <matteo.capr...@gmail.com>
Subject Re: finding documents that fit a range and a list
Date Sat, 12 Dec 2009 22:34:49 GMT
thanks Zachary, feel much reassured :)

On Sat, Dec 12, 2009 at 7:54 PM, Zachary Zolton
<zachary.zolton@gmail.com> wrote:
> I think combining a range query to a view with additional filtering
> via a list function is the current state of the art for these kinds of
> queries in CouchDB. Alternatively, you could probably use
> CouchDB-Lucene, but dealing the dates wouldn't dates wouldn't be so
> straightforward...
>
> On Fri, Dec 11, 2009 at 8:01 AM, Matteo Caprari
> <matteo.caprari@gmail.com> wrote:
>> Hi.
>>
>> I'm trying to find all documents that fit in a key range and that have
>> a property that is included in a list,
>> something in SQL would be
>>
>> date > '2007-07-07' AND  date < '2008-08-08' AND tx IN ('transfer','purchase')
>>
>> To do that I wrote a view and list
>> where the list and the map are
>>
>> views/tx_by_date/map.js:
>> function(doc) {
>>    emit(doc.date, { tx: doc.tx, id:doc.id });
>> }
>>
>> lists/filter.js:
>> function(head, req) {
>>        var filter = req.query.filter.split(',');
>>        while(row = getRow()) {
>>                if (filter.indexOf(row.value.tx) != -1) {
>>                        send(row.value.id+'\n')
>>                }
>>        }
>> }
>> and execute the query with I'm
>> _list/filter/tx_by_date?startkey=2007-07-07&endkey=2008-08-08&filter=transfer,purchase
>>
>> Does this make any sense?
>> Is it a good idea to use _lists for stuff like this?
>> Are there better ways to do that?
>>
>> Thanks!
>> --
>> :Matteo Caprari
>> matteo.caprari@gmail.com
>>
>



-- 
:Matteo Caprari
matteo.caprari@gmail.com

Mime
View raw message