incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@mfdz.com>
Subject Re: mapping on a key that doesn't exist
Date Tue, 13 May 2008 22:31:36 GMT
On Tue, May 13, 2008 at 3:04 PM, Jan Lehnardt <jan@apache.org> wrote:
>
> On May 13, 2008, at 23:19, Bob Briski wrote:
>
>> I've found that I can't create a view with a key that includes a document
>> key that doesn't exist in all documents.

You could try this simplification as a way to create a default value
in the case of undefined:

function(doc) {
  if(doc.type=="Performance") {
    map([doc.product_id, (doc.tracking_code||null), doc.date], doc);
  }
}

The use of || as a guard statement in this way ought to work just
fine. You can use anything you want instead of null as the default.

-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message