Style police!

On 2 Sep 2009, at 19:00, Simon Metson wrote:

Hi,
        Do you mean you want to emit each user as a key? Something like:

function(doc) { for (v in doc.users) { emit(doc.users[v], doc); }

is better written as

function(doc) { for (var v in doc.users) { emit(doc.users[v], doc); }

if you leave out the `var` you create a global variable (as opposed to a local variable in JS and that can have funky effects.

better yet:

function(doc) { if(doc.users) { for (var v in doc.users) { emit (doc.users[v], doc); }}

protects you against errors for documents that doesn't have a `users` property.

otherwise, excellent advice! :)

Cheers
Jan
--



as a map would do that.
Cheers
Simon

On 2 Sep 2009, at 17:25, Jehan Bihin wrote:

Hi all,

(sorry for my english)
I have a document having a list of persons :

...
"users":{"membre-joouul_hotmail.com":["createur"],"membre- killan_daaboo.net
":["moderateur"]}
...

Each persons have some roles.
My key is the membre like 'membre-joouul_hotmail.com'
And i want to list all document having my key present in the users list.

Is it possible and correct to have it ?
Can you guide me ? After reading here and the site I found nothing talking
on that.

Thanks in advance,

Jehan


Reply via email to