Hey Jan,

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.

What he said.

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.

Yeah, I was going to add that but was being lazy ;) apologies!
Cheers
Simon

Reply via email to