From user-return-3677-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Mon Feb 23 20:07:12 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 82761 invoked from network); 23 Feb 2009 20:07:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Feb 2009 20:07:12 -0000 Received: (qmail 15399 invoked by uid 500); 23 Feb 2009 20:07:05 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 15347 invoked by uid 500); 23 Feb 2009 20:07:05 -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 15336 invoked by uid 99); 23 Feb 2009 20:07:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Feb 2009 12:07:05 -0800 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [66.111.4.26] (HELO out2.smtp.messagingengine.com) (66.111.4.26) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Feb 2009 20:06:56 +0000 Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id A77CB2A14C9; Mon, 23 Feb 2009 15:06:35 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Mon, 23 Feb 2009 15:06:35 -0500 X-Sasl-enc: /ZSbPzwyvXDEEd99uxwSh8+WyeYnXU6QHaTCdbV6Bhye 1235419595 Received: from ginosko.ndrix.org (75-164-74-23.tcsn.qwest.net [75.164.74.23]) by mail.messagingengine.com (Postfix) with ESMTPSA id 1C3792ECBF; Mon, 23 Feb 2009 15:06:35 -0500 (EST) Received: by ginosko.ndrix.org (Postfix, from userid 501) id D1437A57238; Mon, 23 Feb 2009 13:06:32 -0700 (MST) Date: Mon, 23 Feb 2009 13:06:32 -0700 From: Michael Hendricks To: user@couchdb.apache.org Cc: net-couchdb@googlegroups.com Subject: Re: Net::CouchDb and views Message-ID: <20090223200632.GJ3606@ginosko.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Feb 23, 2009 at 12:06:29PM +0100, Wout Mertens wrote: > I'm trying to convert a Perl script from RDBMS to CouchDB and thus I > turned to Net::CouchDb (btw, why CouchDb and not CouchDB?). It > doesn't currently seem to have an easy interface for reading views, > so you have to use the call() function which does a plain REST call. > > The most difficult part to find out was how to handle the results from a > call, since they're a pointer to a hash and the rows member is a pointer > to an array of hashes. It would be nice if that could be abstracted away, > for example behind an iterator interface. Net::CouchDb on CPAN hasn't been updated in a long time. There's a complete rewrite of that module named Net::CouchDB hosted on GitHub. It will eventually replace that module. http://github.com/mndrix/net-couchdb With that module, your specific use case would be something like: my $results = $design->view('all'); my %images; while ( my $row = $view->next ) { $images{ $row->{id} } = $row->document; } include_docs isn't supported yet, but patches are welcome. I've cc'd the module's Google Group. > The images/all view is a simple > function(doc) { doc.imgvmxpath && doc.imgname && emit(null, null); } > which selects all documents that have those 2 keys in them. > > I thought that emitting (null,null) and instead using the include_docs > option would keep the size of the view results to a minimum. > Is that thinking correct? Does this incur overhead in different ways? Yes, I think that's the best way to get the information you want out of CouchDB. -- Michael