incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <simonmet...@googlemail.com>
Subject Re: View to find someone in a list in a document
Date Wed, 02 Sep 2009 20:18:12 GMT
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

Mime
View raw message