couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Introduction_to_CouchDB_views" by SebastianCohnen
Date Tue, 23 Feb 2010 09:51:29 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Introduction_to_CouchDB_views" page has been changed by SebastianCohnen.
The comment on this change is: Added TOC; added sytax HL for JS-Code.
http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views?action=diff&rev1=31&rev2=32

--------------------------------------------------

+ = Introduction to CouchDB Views =
+ <<TableOfContents(2)>>
+ 
  A simple introduction to CouchDB views.
  
  == Concept ==
@@ -23, +26 @@

  === Map Functions ===
  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 == "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 would use that property
for the key. For example, the following view would allow you to lookup customer documents
by the ''!LastName'' or ''!FirstName'' fields:
  
- {{{
+ {{{#!highlight javascript
  function(doc) {
    if (doc.Type == "customer") {
      emit(doc.LastName, {FirstName: doc.FirstName, Address: doc.Address});

Mime
View raw message