incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jehan Bihin <squellett...@gmail.com>
Subject Re: View to find someone in a list in a document
Date Wed, 02 Sep 2009 21:02:25 GMT
Thanks guys for your help ! :)


2009/9/2 Simon Metson <simonmetson@googlemail.com>

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message