Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 86170 invoked from network); 11 Dec 2009 14:02:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Dec 2009 14:02:45 -0000 Received: (qmail 29734 invoked by uid 500); 11 Dec 2009 14:02:44 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 29649 invoked by uid 500); 11 Dec 2009 14:02:43 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 29638 invoked by uid 99); 11 Dec 2009 14:02:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Dec 2009 14:02:43 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of matteo.caprari@gmail.com designates 72.14.220.154 as permitted sender) Received: from [72.14.220.154] (HELO fg-out-1718.google.com) (72.14.220.154) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Dec 2009 14:02:36 +0000 Received: by fg-out-1718.google.com with SMTP id 16so159868fgg.5 for ; Fri, 11 Dec 2009 06:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=YpmWch7oDxFVKlQqUwOu93U4KwNQ9dwAzynG6eYBh7g=; b=Yg27YykalIZm8x4xRAHC0M2FDs2cdPUty6QF/W75g8jaqLNGpTKtRhHkuH7eevv/sL Rdn2YgnhWqLD3fvuzTgDBeoqKaK/CrMVZbQ1Rq4tTnTiJ2ilY+dl94HHAo71vRjgsfYE KxOND0m/cFlHhLs0Oxqj55OAHjr6gowdWMk5o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=wzRDkG5L1Mo5wn/1sH02PPQPdbDn0R+TvGs8TJ8xDHSvd050CIdn861uzk8hjjztGp oKOJZqnZmjVY7x6G8/7mikOL+dI/cWRG030ZxS6dZ84PFAVETJDgMWc/BfmCg9yelbbi h28YrM/+SqsqVYU4UvluiiM0LlYGaVyzAZo/o= MIME-Version: 1.0 Received: by 10.216.85.209 with SMTP id u59mr520345wee.109.1260540136266; Fri, 11 Dec 2009 06:02:16 -0800 (PST) From: Matteo Caprari Date: Fri, 11 Dec 2009 14:01:56 +0000 Message-ID: <1bca98390912110601j46d22d0ek183b8ea53b6f7414@mail.gmail.com> Subject: finding documents that fit a range and a list To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org 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