couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matteo Caprari <matteo.capr...@gmail.com>
Subject finding documents that fit a range and a list
Date Fri, 11 Dec 2009 14:01:56 GMT
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

Mime
View raw message