Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 43464 invoked from network); 23 Feb 2010 09:51:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Feb 2010 09:51:53 -0000 Received: (qmail 47333 invoked by uid 500); 23 Feb 2010 09:51:53 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 47248 invoked by uid 500); 23 Feb 2010 09:51:52 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 47239 invoked by uid 500); 23 Feb 2010 09:51:52 -0000 Delivered-To: apmail-incubator-couchdb-commits@incubator.apache.org Received: (qmail 47236 invoked by uid 99); 23 Feb 2010 09:51:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2010 09:51:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2010 09:51:50 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 882BD16E2F; Tue, 23 Feb 2010 09:51:29 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Tue, 23 Feb 2010 09:51:29 -0000 Message-ID: <20100223095129.29009.97366@eos.apache.org> Subject: =?utf-8?q?=5BCouchdb_Wiki=5D_Update_of_=22Introduction=5Fto=5FCouchDB=5Fv?= =?utf-8?q?iews=22_by_SebastianCohnen?= X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for c= hange notification. The "Introduction_to_CouchDB_views" page has been changed by SebastianCohne= n. The comment on this change is: Added TOC; added sytax HL for JS-Code. http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views?action=3Ddiff&= rev1=3D31&rev2=3D32 -------------------------------------------------- + =3D Introduction to CouchDB Views =3D + <> + = A simple introduction to CouchDB views. = =3D=3D Concept =3D=3D @@ -23, +26 @@ =3D=3D=3D Map Functions =3D=3D=3D Here is the simplest example of a map function: = - {{{ + {{{#!highlight javascript function(doc) { emit(null, doc); } @@ -34, +37 @@ = Here is a slightly more complex example of a function that defines a view= on values computed from customer documents: = - {{{ + {{{#!highlight javascript function(doc) { if (doc.Type =3D=3D "customer") { emit(null, {LastName: doc.LastName, FirstName: doc.FirstName, Address= : doc.Address}); @@ -45, +48 @@ = To be able to filter or sort the view by some document property, you woul= d use that property for the key. For example, the following view would allo= w you to lookup customer documents by the ''!LastName'' or ''!FirstName'' f= ields: = - {{{ + {{{#!highlight javascript function(doc) { if (doc.Type =3D=3D "customer") { emit(doc.LastName, {FirstName: doc.FirstName, Address: doc.Address});