Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 81531 invoked from network); 23 Nov 2008 02:20:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Nov 2008 02:20:48 -0000 Received: (qmail 99955 invoked by uid 500); 23 Nov 2008 02:20:56 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 99920 invoked by uid 500); 23 Nov 2008 02:20:56 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 99909 invoked by uid 99); 23 Nov 2008 02:20:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Nov 2008 18:20:56 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [64.22.68.8] (HELO assmule.apisnetworks.com) (64.22.68.8) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Nov 2008 02:19:31 +0000 Received: from [192.168.0.11] (206-248-172-247.dsl.teksavvy.com [206.248.172.247]) by assmule.apisnetworks.com (Postfix) with ESMTPSA id 9A34A2745C4 for ; Sat, 22 Nov 2008 21:19:45 -0500 (EST) Message-ID: <4928BDBE.5000801@silencegreys.com> Date: Sat, 22 Nov 2008 21:19:42 -0500 From: Jedediah Smith User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: couchdb-user@incubator.apache.org Subject: sums by date view Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Let's say I have a couchdb full of documents representing transactions e.g. { type: "transaction", account: "bob", date: "2008-11-22 21:01:00", amount: 123.45 } where amount can be positive or negative, representing a credit or debit respectively I want a view of balance by account and date i.e. given an account and date, get the sum of all transaction amounts for that account, up to that date. Can this be done with only a couchdb view while meeting these requirements: - no client logic - no storing intermediate data in documents - optimal use of incremental view updates (adding/updating a transaction only invalidates view rows with same or later date) If not, what's the best compromise that minimizes client logic?