You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mario Scheliga <ma...@sourcegarden.de> on 2010/02/21 18:14:55 UTC

available JavaScript Functions in View

Hi folks,

i can't stop asking. which javascript functions are available in map,  
reduce, show, list and update functions?

I suggest there are jquery-functions also then the sha1-function  
available. (saw them in tuts). Is that right that
all javascript includes in the share/www/scripts -directory is to my  
hand?

thx alot
mario


--
Sourcegarden GmbH HR: B-104357
Steuernummer: 37/167/21214 USt-ID: DE814784953
Geschaeftsfuehrer: Mario Scheliga, Rene Otto
Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
Schoenhauser Allee 51, 10437 Berlin


Re: available JavaScript Functions in View

Posted by J Chris Anderson <jc...@gmail.com>.
On Feb 21, 2010, at 12:33 PM, Mario Scheliga wrote:

> hi chris,
> 
> i just saw this, was the first place i've looked. But in your presenation i saw this code:
> 
> function(doc) {
> 	var pathToShop = ["planet", "country", "state",
> 	"county", "city", "street"].map(function(field) {
> 		return doc[field];
> 	});
> 	emit(pathToShop, doc.shop);
> };
> 

array.map() is a standard part of JavaScript

> and in a security tutorial from JDavis appears that sha1 stuff:
> 

you can use couchapp macros to include other functions in your functions. so in Jason's case he probably has the base64() function defined somewhere in his source code.

> "The final step is to create a special _design/_auth design document containing a users view mapping usernames to {password_sha: base64(sha1(password)), salt: <random salt>, roles: [<role name>, ...]} and a secret member."
> 
> so i am confused. where are the javascript functions implemented, grepping around the code always get me in wrong direction :-)

see http://github.com/jchris/sofa/blob/master/shows/post.js#L4 for an example usage of a couchapp macro

and for more documentation, grep this link for "!code":

http://github.com/couchapp/couchapp


> 
> thx alot for your time
> mario
> 

glad to help!

Chris

> 
> 
> Am 21.02.2010 um 18:24 schrieb J Chris Anderson:
> 
>> 
>> On Feb 21, 2010, at 12:14 PM, Mario Scheliga wrote:
>> 
>>> Hi folks,
>>> 
>>> i can't stop asking. which javascript functions are available in map, reduce, show, list and update functions?
>>> 
>>> I suggest there are jquery-functions also then the sha1-function available. (saw them in tuts). Is that right that
>>> all javascript includes in the share/www/scripts -directory is to my hand?
>> 
>> no, pretty much all that is available in the query server sandbox (aside from code you inline into your functions yourself) is what is added to it here:
>> 
>> http://github.com/apache/couchdb/blob/trunk/share/server/loop.js#L15
>> 
>>> 
>>> thx alot
>>> mario
>>> 
>>> 
>>> --
>>> Sourcegarden GmbH HR: B-104357
>>> Steuernummer: 37/167/21214 USt-ID: DE814784953
>>> Geschaeftsfuehrer: Mario Scheliga, Rene Otto
>>> Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
>>> Schoenhauser Allee 51, 10437 Berlin
>>> 
>> 
> 
> 
> --
> Sourcegarden GmbH HR: B-104357
> Steuernummer: 37/167/21214 USt-ID: DE814784953
> Geschaeftsfuehrer: Mario Scheliga, Rene Otto
> Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
> Schoenhauser Allee 51, 10437 Berlin
> 


Re: available JavaScript Functions in View

Posted by Mario Scheliga <ma...@sourcegarden.de>.
hi chris,

i just saw this, was the first place i've looked. But in your  
presenation i saw this code:

function(doc) {
	var pathToShop = ["planet", "country", "state",
	"county", "city", "street"].map(function(field) {
		return doc[field];
	});
	emit(pathToShop, doc.shop);
};

and in a security tutorial from JDavis appears that sha1 stuff:

"The final step is to create a special _design/_auth design document  
containing a users view mapping usernames to {password_sha:  
base64(sha1(password)), salt: <random salt>, roles: [<role  
name>, ...]} and a secret member."

so i am confused. where are the javascript functions implemented,  
grepping around the code always get me in wrong direction :-)

thx alot for your time
mario



Am 21.02.2010 um 18:24 schrieb J Chris Anderson:

>
> On Feb 21, 2010, at 12:14 PM, Mario Scheliga wrote:
>
>> Hi folks,
>>
>> i can't stop asking. which javascript functions are available in  
>> map, reduce, show, list and update functions?
>>
>> I suggest there are jquery-functions also then the sha1-function  
>> available. (saw them in tuts). Is that right that
>> all javascript includes in the share/www/scripts -directory is to  
>> my hand?
>
> no, pretty much all that is available in the query server sandbox  
> (aside from code you inline into your functions yourself) is what is  
> added to it here:
>
> http://github.com/apache/couchdb/blob/trunk/share/server/loop.js#L15
>
>>
>> thx alot
>> mario
>>
>>
>> --
>> Sourcegarden GmbH HR: B-104357
>> Steuernummer: 37/167/21214 USt-ID: DE814784953
>> Geschaeftsfuehrer: Mario Scheliga, Rene Otto
>> Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
>> Schoenhauser Allee 51, 10437 Berlin
>>
>


--
Sourcegarden GmbH HR: B-104357
Steuernummer: 37/167/21214 USt-ID: DE814784953
Geschaeftsfuehrer: Mario Scheliga, Rene Otto
Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
Schoenhauser Allee 51, 10437 Berlin


Re: available JavaScript Functions in View

Posted by J Chris Anderson <jc...@gmail.com>.
On Feb 21, 2010, at 12:14 PM, Mario Scheliga wrote:

> Hi folks,
> 
> i can't stop asking. which javascript functions are available in map, reduce, show, list and update functions?
> 
> I suggest there are jquery-functions also then the sha1-function available. (saw them in tuts). Is that right that
> all javascript includes in the share/www/scripts -directory is to my hand?

no, pretty much all that is available in the query server sandbox (aside from code you inline into your functions yourself) is what is added to it here:

http://github.com/apache/couchdb/blob/trunk/share/server/loop.js#L15

> 
> thx alot
> mario
> 
> 
> --
> Sourcegarden GmbH HR: B-104357
> Steuernummer: 37/167/21214 USt-ID: DE814784953
> Geschaeftsfuehrer: Mario Scheliga, Rene Otto
> Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
> Schoenhauser Allee 51, 10437 Berlin
>