You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Vincent Lextrait <vi...@gmail.com> on 2016/12/01 01:00:56 UTC

emit with key 0

Hello,

There must be something I do which is badly wrong, I am using emit with a
numeric key. It is so simple that I cannot believe it is a couchdb bug.
It works fine with all keys which are not 0, and documents are properly
inserted in the view. When the key is 0, emit does not seem to generate an
insertion in the view.
Any idea?

Thanks a lot,
Vincent

Re: emit with key 0

Posted by Vincent Lextrait <vi...@gmail.com>.
Thanks, Stefan, that was my problem. A fresh pair of eyes is always
welcome. Very very silly.
I did not pay enough attention to the fact that most of the code given as
examples for views is actually designed for string keys. It requires more
care to make it work for any type.
Vincent

On Thu, Dec 1, 2016 at 4:06 AM, Stefan du Fresne <st...@medicmobile.org>
wrote:

> It’s hard to tell from your post, but note that 0 is falsy in Javascript,
> so if you’re doing something like “if (value) { emit(value) }” then values
> of 0 will not get emitted.
>
> Stefan
> > On 1 Dec 2016, at 01:00, Vincent Lextrait <vi...@gmail.com>
> wrote:
> >
> > Hello,
> >
> > There must be something I do which is badly wrong, I am using emit with a
> > numeric key. It is so simple that I cannot believe it is a couchdb bug.
> > It works fine with all keys which are not 0, and documents are properly
> > inserted in the view. When the key is 0, emit does not seem to generate
> an
> > insertion in the view.
> > Any idea?
> >
> > Thanks a lot,
> > Vincent
>
>

Re: emit with key 0

Posted by Stefan du Fresne <st...@medicmobile.org>.
It’s hard to tell from your post, but note that 0 is falsy in Javascript, so if you’re doing something like “if (value) { emit(value) }” then values of 0 will not get emitted.

Stefan
> On 1 Dec 2016, at 01:00, Vincent Lextrait <vi...@gmail.com> wrote:
> 
> Hello,
> 
> There must be something I do which is badly wrong, I am using emit with a
> numeric key. It is so simple that I cannot believe it is a couchdb bug.
> It works fine with all keys which are not 0, and documents are properly
> inserted in the view. When the key is 0, emit does not seem to generate an
> insertion in the view.
> Any idea?
> 
> Thanks a lot,
> Vincent