Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 19932 invoked from network); 17 Jul 2009 12:59:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Jul 2009 12:59:22 -0000 Received: (qmail 53804 invoked by uid 500); 17 Jul 2009 13:00:26 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 53703 invoked by uid 500); 17 Jul 2009 13:00:26 -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 53672 invoked by uid 99); 17 Jul 2009 13:00:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jul 2009 13:00:24 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.217.225 as permitted sender) Received: from [209.85.217.225] (HELO mail-gx0-f225.google.com) (209.85.217.225) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jul 2009 13:00:15 +0000 Received: by gxk25 with SMTP id 25so1423811gxk.11 for ; Fri, 17 Jul 2009 05:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=/iV5OHSgfxE6bSVV3OPHywWR8mmtYZYsh2eniin+vBo=; b=m1yUElV3wwj0Vj/pFLEH/Ouey6TUkSB60X4UbE60H1U9/HEq1JzL3Mi1tIwwHYPdP+ rBJkPgniS5JsAOrGtVUK7v8tomMUNj8uD/sXvUrknFSdl80FzyNNtYSPYQLYI3wBkB4K QwrqtEngU8/x+H/LTSJwGi2iMXoygkOulrLO8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=feyZNV/id/d0Uisj7QfeBbiXvtzSMXLTUnoaKD+yHkiSJa077pzzLAuN5iIyJSs0YM 9nTEkfHRr7DXlKab9IwmsyXynHMNTPh2rxUdlV7rwRoqUSvlSPgxzVAzZZO5aVhuYcpm BR1bClsNZGRwOSCZlkwjBBFSiV29YsJ2UpcdY= MIME-Version: 1.0 Received: by 10.100.119.17 with SMTP id r17mr1516412anc.3.1247835594073; Fri, 17 Jul 2009 05:59:54 -0700 (PDT) In-Reply-To: References: <20090717125142.E6A433000204@bmail00.one.com> Date: Fri, 17 Jul 2009 08:59:53 -0400 Message-ID: Subject: Re: Dynamic permanent views From: Paul Davis To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Keyboard fail... { "_id": "_design/baz", "views": { "by_resource": { "map": "function(doc) {emit(doc[\"@resource_id\"], doc.id);}" } } } And query the view with: http://127.0.0.1:5984/db_name/_design/baz/_view/by_resource?key="my_resource_id" On Fri, Jul 17, 2009 at 8:57 AM, Paul Davis wrote: > Create a design document that looks like this: > > { > > > On Fri, Jul 17, 2009 at 8:51 AM, wrote: >> I'm trying to write a view that enables me to extract data from my couch >> depending on what variables I'm passing to it. >> >> Here is an example of what an entry in the db might look like: >> >> >> { >> "@type": "LocationHelperTest", >> "_id": "cad119d5abf74997a1dac4ca8ca6b266", >> "_rev": "2526720230", >> "name": "Test", >> "what": { >> "@new": 1, >> "@old": null, >> "@resource_id": "21716c48bc8211a522f0ac684acb1ea8" >> }, >> "when": { >> "@recieved": "2009-07-17T07:08:04.765000" >> }, >> "who": { >> "user_id": "user" >> }, >> "why": { >> "new_state": "new state", >> "old_state": "old state", >> "reason": "A random reason" >> } >> } >> >> >> As you can see, I have a field, @resource_id, in the "what" dict. This >> is the same as the ID for another entry in the db that is called >> LocationTest. I'm using Pylons to write my system, and through the URL I >> get the ID. With this ID I want to find all LocationHelperTests with the >> @resource_id that matches this ID. >> >> How do I do this with views? (Or any other way if there is any). I'm not >> interested in temporary views, but wants a permanten view. >> >