incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Re: Properties with special characters
Date Fri, 07 Aug 2009 12:19:41 GMT
On Fri, Aug 07, 2009 at 08:39:14PM +0930, Antony Blakey wrote:
>
> On 07/08/2009, at 8:25 PM, Tim Somers wrote:
>
>> function(doc) {
>>    if (doc.doc_type == "multiLangString") {
>>        emit(doc.default, {
>>            "default": doc.default,
>>            "en-GB": doc.en-GB,
>>            "fr-BE": doc.fr-BE,
>>            "nl-BE": doc.nl-BE
>>        });
>>    }
>> }
>
> In javascript, doc.en-GB is actually doc.en - GB i.e. a subtration  
> operation.
>
> You need to do this:
>
>   "en-GB": doc['en-GB'],
>   "fr-BE": doc['fr-BE'],
>   "nl-BE": doc['nl-BE']
>
> This is a general Javascript trap.

And if it might not be present, then

  "en-GB": doc['en-GB'] || null,

... etc
(otherwise you will get 'undefined' and couch-js falls over when trying to
serialize it)

You can of course just do
  emit(doc.default, doc);

to get the whole document, or

  emit(doc.default, null);

which emits no value, but since you have the docid you can query with
?include_docs=true

HTH,

Brian.

Mime
View raw message