couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Weber <>
Subject Re: Design docs and javascript function unreadable...?
Date Thu, 20 Dec 2012 14:36:44 GMT
Ok, than can someone provide a definition of 'CouchApp'...?

I googled and found a 'couchapp'.  I followed the instructions, which were to 
attach an Index.html file to a design document.  Then when I browse to the 'couchapp' just gives me a 
list of the databases in the server (hyperlinked).  If I click on one, it 
redirects me back to Futon.

It would appear there is some big unexplained world of couch 'APPS' out there, 
unrelated to what I found in the online book.

----- Original Message ----
From: Aliaksandr Barysiuk <>
Sent: Thu, December 20, 2012 12:43:03 AM
Subject: Re: Design docs and javascript function unreadable...?


As Robert Newson mentioned you can edit files locally in your favorite editor 
and then use couchapp (kanso, erica?) to 

push the app to couchdb.



On 20/12/12 04:32, Scott Weber wrote:
> Mark,
> I am looking at the JSON string because FUTON is the only tool I have that 
> me an interface.
> I also took the JSON dos and put it in a file, and used curl to upload it.  It
> still rejects it.
> In both cases, these are the only tools I am aware of. They are the only 
> described in the tutorial book.  They are the instructions I am following.
> The online book functions all have newlines, tabs, comments, etc...  It is 
> natural that someone reading it would copy and paste them into the design doc 
> order to test.
> My example design doc is below.  It only can be installed (using FUTON or 
> when all the whitespace is stripped out manually by me.
> I cannot see how manually creating a slightly more complex function then these
> examples would not be begging for mistakes when forced to de-beautify it
> manually for loading in through FUTON or curl.
> There is no way to just tell "validate_doc_update" to load a function from a
> whatever.js file?  So the function can remain readable?
> {
>     "_id": "_design/example",
>     "_rev": "4-942673df70142b3c1d181628f93e1184",
>     "validate_doc_update":
> "function(newDoc, oldDoc, userCtx) {
> function require(field, message) {
> message = message ||  field;
> throw({forbidden : message});
> };
> if (!newDoc.session) { return;  } // if it's not a session document...
> if (newdoc.BoxNumber && (newdoc.BoxNumber) != oldDoc.BoxNumber)) {
> require('BoxNumber','Box Number cannot change');
> }
> }",
>     "views": {
>         "foo": {
>             "map": "function(doc){ emit(doc._id, doc._rev)}"
>         }
>     }
> }
> ----- Original Message ----
> From: Mark Hahn <>
> To: user <>
> Sent: Wed, December 19, 2012 6:29:54 PM
> Subject: Re: Design docs and javascript function unreadable...?
> Seriously.
> It is stored as json and control chars aren't allowed in json strings.
> All tools should handle the conversion in and out.  Futon handles it
> fine.  My custom scripts handle it fine.  Why would you be looking at
> the json string directly?
> On Wed, Dec 19, 2012 at 4:08 PM, Scott Weber <> wrote:
>> Clearly, this can't be the way it is supposed to behave.
>> I must be missing something, somewhere...
>> In a design doc, I put a function to validate.  I used to validate_doc_update
>> key of the design JSON.  All taken from examples in the guide. Then I found
>> out...
>> The javascript in the design doc cannot have newlines..?  cannot have tabs..?
>> Cannot be formatted so that it's readable..?  Seriously?
>> There has to be a way to put readable code into this.  What am I missing?  
>> the code in the "The Definitive Guide' is loaded with comments, line breaks,
>> etc...
>> -Scott

View raw message