incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcello Nuccio <>
Subject Re: Allowed contents of validate_doc_update field.
Date Tue, 04 Oct 2011 12:37:36 GMT
2011/10/4 Jason Smith <>:
> I would stick to a pure-function. What if you set `a = /not_bla/` in
> the function? But CouchDB might start many simultaneous Javascript
> processes, so you will not know the value of `a` later.
> I admit that sometimes I wish I could put constants and other things
> outside the function, for readability.

I'm not doing it for readability, or performance.
I'm trying to share common code between the client (browser), the
server (CouchDB), the backend, and support scripts (node.js).

Node and CouchDB have both CommonJS, but on the browser there's no
CommonJS, so I'm using RequireJS[1]. It works great, but I've not
managed to get it working with js-test-driver[2]. So, to get the job
done, in some places I'm doing file concatenation. And that is why
something is declared outside of validate_doc_update function.


> P.S. /regex/.test(str) does not work on some builds of CouchDB (or
> rather, some builds of Spidermonkey) which are still in use. It is
> safer to use str.match(/regex) which I also find less readable :)

Yes I know. I was about to submit a bug report a while ago, but
suddenly it started working an I forgot about it :-).


> On Tue, Oct 4, 2011 at 3:35 PM, Marcello Nuccio
> <> wrote:
>> Is it supported to put anything other than an anonymous function in
>> the validate_doc_update field of a design document?
>> For example:
>>    var a = /bla/;
>>    function (doc, oldDoc, userCtx, secObj) {
>>        if (!a.test(doc._id)) ...
>>    }
>> is it supported or it can work only by coincidence.
>> Thanks,
>>  Marcello
> --
> Iris Couch

View raw message