couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Somers <tim.som...@securysat.be>
Subject Properties with special characters
Date Fri, 07 Aug 2009 10:55:46 GMT
Hi all,

I'm using couchdb to store some localization strings. A typical document
looks like this:

{
    "_id":"1962a07f8a56ba935f6d5370928dd483",
   "_rev":"3-2493355664",
    "default":"closed",
   "doc_type":"multiLangString",
    "fr-BE":"cl\u00f4tur\u00e9",
   "nl-BE":"afgesloten"
}

So far, so good. Now, I'm trying to get a view running with all translations
ordered by "default" :

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
        });
    }
}

This version just gives nothing at all. If I remove the "-" from the field
names (enGB, frBE and nlBE) it outputs only the default values, as expected.
If I adapt the documents it works like it should, except for my application
which is trying to reusing an existing variable. If I try escaping (en\-GB,
nl\-BE and fr\-BE), I get an error :

Error: badmatch

{{bad_return_value,{os_process_error,{exit_status,0}}},
 {gen_server,call,
             [<0.19293.25>,
              {prompt,[<<"add_fun">>,
                       <<"function(doc) {\n\tif (doc.doc_type ==
\"multiLangString\") {\n\t\temit(doc.default, {\n\t\t\t\"default\":
doc.default,\n\t\t\t\"en-GB\": doc.en\\-GB,\n\t\t\t\"fr-BE\":
doc.fr\\-BE,\n\t\t\t\"nl-BE\":
doc.nl\\-BE\n\t\t});\n\t}\n}\n\n">>]},
              infinity]}}

I'm using the 0.9.0 version from debian testing. Any idea how to get this
view running?

Thanks
Tim

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message