couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Better way to count attachments?
Date Sat, 17 Jan 2009 12:59:07 GMT

On 17 Jan 2009, at 01:51, Bradford Winfrey wrote:

> I thought spidermonkey provided a __count__ method, sorry to  
> justtjink aloud, out and about at the moment

It does https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object
and it works for me (Spidermonkey 1.7), but it is nonstandard and we  
shouldn't encourage its
use.


>
>
> Sent from my iPod
>
> On Jan 16, 2009, at 6:44 PM, "Jeff Hinrichs - DM&T" <jeffh@dundeemt.com 
> > wrote:
>
> I am writing a view where the number of attachments is emit'd
>
> function(doc) {
>   var cnt = 0;
>   for (var att in doc._attachments){
>     cnt = cnt+1;
>   }
>   emit(cnt,doc._attachments);
> }
>
> Is what I came up with.  Is there a more elegant solution than this?
>
>
> Regards,
>
> Jeff
>
>
>
>
>


Mime
View raw message