You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stephan Bardubitzki <st...@bardubitzki.com> on 2012/01/27 03:48:43 UTC

_design doc issue

I'm quite new to CouchDB and have to struggle with the following issue 
using Futon:

In 'temporary view' this code does what I want to get out:

function(doc) {
   var today = new Date();
   var month = today.getMonth();
   var room, chatrooms = [];
   for ( room in doc.room ) {
       if ( doc.room[room].duration === 'seasonal' || 
doc.room[room].duration === 'ones' ) {
           if ( doc.room[room].start < doc.room[room].end ) {
           if( doc.room[room].start <= month && doc.room[room].end >= 
month ) {
                   chatrooms.push(doc.room[room]);
               }
           }
           else {
           if( doc.room[room].start >= month && doc.room[room].end >= 
month ) {
                   chatrooms.push(doc.room[room]);
               }
           }
       }
       else {
           chatrooms.push(doc.room[room]);
       }

   }
   emit(doc._id, chatrooms);
}

However, if I add this to the _design doc Futon will not save the document.
FF says: JSON.parse: bad control character in string literal.

My _design doc looks like this:

{
    "_id": "_design/chat-categories",
    "_rev": "9-d5bca128d1fb98545691d78fa6aff9bb",
    "views": {
        "categories": {
            "map": "function(doc) {
               var today = new Date();
              var month = today.getMonth();
               var room, chatrooms = [];
               for ( room in doc.room ) {
                       if ( doc.room[room].duration === \"seasonal\" || 
doc.room[room].duration === \"ones\" ) {
                           if ( doc.room[room].start < 
doc.room[room].end ) {
                               if( doc.room[room].start <= month && 
doc.room[room].end >= month ) {
                                       chatrooms.push(doc.room[room]);
                                   }
                           }
                           else {
                               if( doc.room[room].start >= month && 
doc.room[room].end >= month ) {
                                       chatrooms.push(doc.room[room]);
                                   }
                           }
                       }
                       else {
                           chatrooms.push(doc.room[room]);
                       }
                    }
               emit(doc._id, chatrooms);
         }"
         }
     }
}

What do I miss?

Thanks.


Re: _design doc issue

Posted by CGS <cg...@gmail.com>.
Well, that may be correct, I don't know. What I know is that I try my
design documents in Futon to be sure they are working (I do not have so
many design documents, so, I can afford trying them in Futon, especially
because I am a rookie in design documents).

About JSON parser in Erlang, I don't know any "standard" parser, so,
usually, I do my own parsing which, for the simple cases of key-value,
works nicely with the most of the special characters. It may be that the
limitation comes from the JavaScript engine, but not sure. My point is here
that I wouldn't blame Futon for something witch may be out of its reach.
But I might be wrong, of course.

CGS



On Fri, Jan 27, 2012 at 6:02 AM, Jens Alfke <je...@couchbase.com> wrote:

>
> On Jan 26, 2012, at 8:54 PM, Mark Hahn wrote:
>
> That's right.  The CR is the illegal control char.  They parse it with an
> eval and strings can't cross lines.
>
> This is probably only an issue when editing a document in Futon. I don't
> think the JSON parser in Erlang has such a limitation. (One could argue
> that this is a Futon bug; the JSON spec allows any Unicode character in a
> string, though of course quotes and backslashes have to be quoted.)
>
> —Jens
>

Re: re couchapp with node

Posted by Travis Paul <Tr...@visPaul.me>.
In regards to your python couchapp experience, where you using python >=
2.5? Python 3 isn't supported and will give you crazy errors. I don't know
anything about python but I have found the python couchapp to work very
well.

Sorry that I can't help you with your node.js problem I haven't gotten
around to trying it out yet.

On Fri, Jan 27, 2012 at 4:39 PM, john.tiger <jo...@gmail.com>wrote:

> I posted this with node google group but then realized I might get a
> response from this group with more couchapp users.
>
> we're trying to use node.couchapp.js but since it's not very documented
> having trouble figuring out whether base files such as index.html, app.css,
> etc should get added as either:
> a) put under attachments folder and get loaded with loadAttachment
> b) or listed under ddoc and loaded with loadFile
>
>
> we have tried both the python version of couchapp which gave all sorts of
> errors and seems overly complicated  and at Kelso - a node version of
> couchapp which also has way too many dependencies making it quite
> complicated as well - we are hoping to clean up, better document and even
> simplify node.couchapp without dependencies.
>
>

Re: re couchapp with node

Posted by "john.tiger" <jo...@gmail.com>.
okay, I checked it out

we are using python 2.7 (Debian Sid)

couchapp (python) worked okay - apparently when we tested 
backbone-couchdb with couchapp, one of the files was linked, which 
caused errors - fixing this, couchapp seemed to work okay.

the node approach still seems simpler than the more complicated folder 
structure of the python approach but either seems to work for now.



On 01/27/2012 05:53 PM, Benoit Chesneau wrote:
> which errors did you have with the python version? did you use thse single
> installer?
> On Jan 27, 2012 1:40 PM, "john.tiger"<jo...@gmail.com>  wrote:
>
>> I posted this with node google group but then realized I might get a
>> response from this group with more couchapp users.
>>
>> we're trying to use node.couchapp.js but since it's not very documented
>> having trouble figuring out whether base files such as index.html, app.css,
>> etc should get added as either:
>> a) put under attachments folder and get loaded with loadAttachment
>> b) or listed under ddoc and loaded with loadFile
>>
>>
>> we have tried both the python version of couchapp which gave all sorts of
>> errors and seems overly complicated  and at Kelso - a node version of
>> couchapp which also has way too many dependencies making it quite
>> complicated as well - we are hoping to clean up, better document and even
>> simplify node.couchapp without dependencies.
>>
>>


Re: re couchapp with node

Posted by Benoit Chesneau <bc...@gmail.com>.
which errors did you have with the python version? did you use thse single
installer?
On Jan 27, 2012 1:40 PM, "john.tiger" <jo...@gmail.com> wrote:

> I posted this with node google group but then realized I might get a
> response from this group with more couchapp users.
>
> we're trying to use node.couchapp.js but since it's not very documented
> having trouble figuring out whether base files such as index.html, app.css,
> etc should get added as either:
> a) put under attachments folder and get loaded with loadAttachment
> b) or listed under ddoc and loaded with loadFile
>
>
> we have tried both the python version of couchapp which gave all sorts of
> errors and seems overly complicated  and at Kelso - a node version of
> couchapp which also has way too many dependencies making it quite
> complicated as well - we are hoping to clean up, better document and even
> simplify node.couchapp without dependencies.
>
>

Re: re couchapp with node

Posted by David Rose <do...@gmail.com>.
couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments'));
adds all files under the directory "attachments" as attachments to the
design doc.

ddoc.views.lib = couchapp.loadFiles('./lib');
adds any js files in the "./lib" directory as commonjs modules to your
views, which you can then use in your views. Here's a snippet from one
of mine:

ddoc.views.alpha = {
  map : function(doc) {
    if(doc.type == 'event') {
      var skey   = require('views/lib/util').sanitizedKeyData(doc);
      var cvalue = require('views/lib/util').commonEmitValue(doc);
      emit(skey.name, cvalue);
    }
  },
  reduce : "_count"	
}

./lib/utils.js looks like this:

exports.commonEmitValue = function(doc) {
  return({...});
}

exports.sanitizedKeyData = function(doc) {
  // set vars and manipulate stuff
  return({...});
}

You can also define ddoc filters in a similar fashion:

ddoc.filters = couchapp.loadFiles('./filters');

Hope this somewhat incoherent reply helps point you in the right direction.

David Rose


On Fri, Jan 27, 2012 at 3:39 PM, john.tiger <jo...@gmail.com> wrote:
> I posted this with node google group but then realized I might get a
> response from this group with more couchapp users.
>
> we're trying to use node.couchapp.js but since it's not very documented
> having trouble figuring out whether base files such as index.html, app.css,
> etc should get added as either:
> a) put under attachments folder and get loaded with loadAttachment
> b) or listed under ddoc and loaded with loadFile
>
>
> we have tried both the python version of couchapp which gave all sorts of
> errors and seems overly complicated  and at Kelso - a node version of
> couchapp which also has way too many dependencies making it quite
> complicated as well - we are hoping to clean up, better document and even
> simplify node.couchapp without dependencies.
>

re couchapp with node

Posted by "john.tiger" <jo...@gmail.com>.
I posted this with node google group but then realized I might get a 
response from this group with more couchapp users.

we're trying to use node.couchapp.js but since it's not very documented 
having trouble figuring out whether base files such as index.html, 
app.css, etc should get added as either:
a) put under attachments folder and get loaded with loadAttachment
b) or listed under ddoc and loaded with loadFile


we have tried both the python version of couchapp which gave all sorts 
of errors and seems overly complicated  and at Kelso - a node version of 
couchapp which also has way too many dependencies making it quite 
complicated as well - we are hoping to clean up, better document and 
even simplify node.couchapp without dependencies.


Re: _design doc issue

Posted by CGS <cg...@gmail.com>.
I added a note in the CouchDB Wiki page "Getting_started_with_Futon" (
http://wiki.apache.org/couchdb/Getting_started_with_Futon), so, the users
to be warned about this error. Feel free to change the note as you consider.

CGS



On Fri, Jan 27, 2012 at 6:23 AM, CGS <cg...@gmail.com> wrote:

> I ran into that issue before you and that's why I could give you that as a
> possible solution. I am still using Futon. :D
>
> Cheers,
> CGS
>
>
>
>
>
> On Fri, Jan 27, 2012 at 6:16 AM, Stephan Bardubitzki <
> stephan@bardubitzki.com> wrote:
>
>> Thanks guys, that did it.
>>
>> Just wondering why no one else run into this issue before, is it bad
>> practice to use Futon for that?
>>
>> Stephan
>>
>>
>>
>> On 12-01-26 09:02 PM, Jens Alfke wrote:
>>
>>> On Jan 26, 2012, at 8:54 PM, Mark Hahn wrote:
>>>
>>> That's right.  The CR is the illegal control char.  They parse it with an
>>> eval and strings can't cross lines.
>>>
>>> This is probably only an issue when editing a document in Futon. I don't
>>> think the JSON parser in Erlang has such a limitation. (One could argue
>>> that this is a Futon bug; the JSON spec allows any Unicode character in a
>>> string, though of course quotes and backslashes have to be quoted.)
>>>
>>> —Jens
>>>
>>> ------------------------------**--
>>> Spam/Virus scanning by CanIt Pro
>>>
>>> For more information see
>>> http://www.kgbinternet.com/**SpamFilter.htm<http://www.kgbinternet.com/SpamFilter.htm>
>>>
>>> To control your spam filter, log in at
>>> http://filter.kgbinternet.com
>>>
>>>
>

Re: _design doc issue

Posted by Simon Metson <si...@googlemail.com>.
You can emit the doc date/timestamp in the key and use view slicing to filter (not sure if that helps - lost the rest of the thread...). E.g.
Cheers
Simon


On Friday, 27 January 2012 at 16:10, Stephan Bardubitzki wrote:

> No, I wasn't. Thanks.
> 
> So, that means I have to do the filtering outside the db server either 
> on the application server side or on the client side?
> 
> Stephan
> 
> 
> On 12-01-27 03:01 AM, Robert Newson wrote:
> > You're aware that 'var today = new Date();' will be the date of
> > indexing time and not querying time? That is, it will not change
> > unless you update the document.
> > 
> > B.
> > 
> > On 27 January 2012 06:53, Mark Hahn<mark@hahnca.com (mailto:mark@hahnca.com)> wrote:
> > > > I ran into that issue before you
> > > 
> > > ditto
> > > 
> > 
> > --------------------------------
> > Spam/Virus scanning by CanIt Pro
> > 
> > For more information see
> > http://www.kgbinternet.com/SpamFilter.htm
> > 
> > To control your spam filter, log in at
> > http://filter.kgbinternet.com
> > 
> 
> 
> 



Re: _design doc issue

Posted by Stephan Bardubitzki <st...@bardubitzki.com>.
No, I wasn't. Thanks.

So, that means I have to do the filtering outside the db server either 
on the application server side or on the client side?

Stephan


On 12-01-27 03:01 AM, Robert Newson wrote:
> You're aware that 'var today = new Date();' will be the date of
> indexing time and not querying time? That is, it will not change
> unless you update the document.
>
> B.
>
> On 27 January 2012 06:53, Mark Hahn<ma...@hahnca.com>  wrote:
>>>   I ran into that issue before you
>> ditto
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>

Re: _design doc issue

Posted by Robert Newson <rn...@apache.org>.
You're aware that 'var today = new Date();' will be the date of
indexing time and not querying time? That is, it will not change
unless you update the document.

B.

On 27 January 2012 06:53, Mark Hahn <ma...@hahnca.com> wrote:
>>  I ran into that issue before you
>
> ditto

Re: _design doc issue

Posted by Mark Hahn <ma...@hahnca.com>.
>  I ran into that issue before you

ditto

Re: _design doc issue

Posted by CGS <cg...@gmail.com>.
I ran into that issue before you and that's why I could give you that as a
possible solution. I am still using Futon. :D

Cheers,
CGS




On Fri, Jan 27, 2012 at 6:16 AM, Stephan Bardubitzki <
stephan@bardubitzki.com> wrote:

> Thanks guys, that did it.
>
> Just wondering why no one else run into this issue before, is it bad
> practice to use Futon for that?
>
> Stephan
>
>
>
> On 12-01-26 09:02 PM, Jens Alfke wrote:
>
>> On Jan 26, 2012, at 8:54 PM, Mark Hahn wrote:
>>
>> That's right.  The CR is the illegal control char.  They parse it with an
>> eval and strings can't cross lines.
>>
>> This is probably only an issue when editing a document in Futon. I don't
>> think the JSON parser in Erlang has such a limitation. (One could argue
>> that this is a Futon bug; the JSON spec allows any Unicode character in a
>> string, though of course quotes and backslashes have to be quoted.)
>>
>> —Jens
>>
>> ------------------------------**--
>> Spam/Virus scanning by CanIt Pro
>>
>> For more information see
>> http://www.kgbinternet.com/**SpamFilter.htm<http://www.kgbinternet.com/SpamFilter.htm>
>>
>> To control your spam filter, log in at
>> http://filter.kgbinternet.com
>>
>>

Re: _design doc issue

Posted by Stephan Bardubitzki <st...@bardubitzki.com>.
Thanks guys, that did it.

Just wondering why no one else run into this issue before, is it bad 
practice to use Futon for that?

Stephan


On 12-01-26 09:02 PM, Jens Alfke wrote:
> On Jan 26, 2012, at 8:54 PM, Mark Hahn wrote:
>
> That's right.  The CR is the illegal control char.  They parse it with an
> eval and strings can't cross lines.
>
> This is probably only an issue when editing a document in Futon. I don't think the JSON parser in Erlang has such a limitation. (One could argue that this is a Futon bug; the JSON spec allows any Unicode character in a string, though of course quotes and backslashes have to be quoted.)
>
> —Jens
>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>

Re: _design doc issue

Posted by Mark Hahn <ma...@hahnca.com>.
>  This is probably only an issue when editing a document in Futon.

I have all my views in a source tree and I compile them to couch with a
home-made tool.  I seem to remember having to strip out all the CRs in that
tool.

Re: _design doc issue

Posted by Jens Alfke <je...@couchbase.com>.
On Jan 26, 2012, at 8:54 PM, Mark Hahn wrote:

That's right.  The CR is the illegal control char.  They parse it with an
eval and strings can't cross lines.

This is probably only an issue when editing a document in Futon. I don't think the JSON parser in Erlang has such a limitation. (One could argue that this is a Futon bug; the JSON spec allows any Unicode character in a string, though of course quotes and backslashes have to be quoted.)

—Jens

Re: _design doc issue

Posted by Mark Hahn <ma...@hahnca.com>.
>  Try without new lines

That's right.  The CR is the illegal control char.  They parse it with an
eval and strings can't cross lines.

Re: _design doc issue

Posted by CGS <cg...@gmail.com>.
Try without new lines in the map function (write the full function in one
line). That can also raise that error.

CGS



On Fri, Jan 27, 2012 at 5:14 AM, Stephan Bardubitzki <
stephan@bardubitzki.com> wrote:

> Thanks for your reply CGS.
>
> I have use single quota in the first place causing the same issue.
>
> Any more thoughts?
>
> Stephan
>
>
>
> On 12-01-26 08:08 PM, CGS wrote:
>
>> Use single quota ( ' ) instead of escape character and double quota.(\").
>> For some reasons I don't know, the JSON parser is no capable of
>> interpreting \" as it should.
>>
>> CGS
>>
>>
>>
>>
>> On Fri, Jan 27, 2012 at 3:48 AM, Stephan Bardubitzki<
>> stephan@bardubitzki.com>  wrote:
>>
>>  I'm quite new to CouchDB and have to struggle with the following issue
>>> using Futon:
>>>
>>> In 'temporary view' this code does what I want to get out:
>>>
>>> function(doc) {
>>>  var today = new Date();
>>>  var month = today.getMonth();
>>>  var room, chatrooms = [];
>>>  for ( room in doc.room ) {
>>>      if ( doc.room[room].duration === 'seasonal' ||
>>> doc.room[room].duration === 'ones' ) {
>>>          if ( doc.room[room].start<  doc.room[room].end ) {
>>>          if( doc.room[room].start<= month&&  doc.room[room].end>= month
>>> ) {
>>>                  chatrooms.push(doc.room[room])****;
>>>              }
>>>          }
>>>          else {
>>>          if( doc.room[room].start>= month&&  doc.room[room].end>= month
>>> ) {
>>>                  chatrooms.push(doc.room[room])****;
>>>              }
>>>          }
>>>      }
>>>      else {
>>>          chatrooms.push(doc.room[room])****;
>>>
>>>      }
>>>
>>>  }
>>>  emit(doc._id, chatrooms);
>>> }
>>>
>>> However, if I add this to the _design doc Futon will not save the
>>> document.
>>> FF says: JSON.parse: bad control character in string literal.
>>>
>>> My _design doc looks like this:
>>>
>>> {
>>>   "_id": "_design/chat-categories",
>>>   "_rev": "9-****d5bca128d1fb98545691d78fa6aff9****bb",
>>>
>>>   "views": {
>>>       "categories": {
>>>           "map": "function(doc) {
>>>              var today = new Date();
>>>             var month = today.getMonth();
>>>              var room, chatrooms = [];
>>>              for ( room in doc.room ) {
>>>                      if ( doc.room[room].duration === \"seasonal\" ||
>>> doc.room[room].duration === \"ones\" ) {
>>>                          if ( doc.room[room].start<  doc.room[room].end
>>> ) {
>>>                              if( doc.room[room].start<= month&&
>>> doc.room[room].end>= month ) {
>>>                                      chatrooms.push(doc.room[room])****;
>>>
>>>                                  }
>>>                          }
>>>                          else {
>>>                              if( doc.room[room].start>= month&&
>>> doc.room[room].end>= month ) {
>>>                                      chatrooms.push(doc.room[room])****;
>>>                                  }
>>>                          }
>>>                      }
>>>                      else {
>>>                          chatrooms.push(doc.room[room])****;
>>>
>>>                      }
>>>                   }
>>>              emit(doc._id, chatrooms);
>>>        }"
>>>        }
>>>    }
>>> }
>>>
>>> What do I miss?
>>>
>>> Thanks.
>>>
>>>
>>>  ------------------------------**--
>> Spam/Virus scanning by CanIt Pro
>>
>> For more information see
>> http://www.kgbinternet.com/**SpamFilter.htm<http://www.kgbinternet.com/SpamFilter.htm>
>>
>> To control your spam filter, log in at
>> http://filter.kgbinternet.com
>>
>>

Re: _design doc issue

Posted by Stephan Bardubitzki <st...@bardubitzki.com>.
Thanks for your reply CGS.

I have use single quota in the first place causing the same issue.

Any more thoughts?

Stephan


On 12-01-26 08:08 PM, CGS wrote:
> Use single quota ( ' ) instead of escape character and double quota.(\").
> For some reasons I don't know, the JSON parser is no capable of
> interpreting \" as it should.
>
> CGS
>
>
>
>
> On Fri, Jan 27, 2012 at 3:48 AM, Stephan Bardubitzki<
> stephan@bardubitzki.com>  wrote:
>
>> I'm quite new to CouchDB and have to struggle with the following issue
>> using Futon:
>>
>> In 'temporary view' this code does what I want to get out:
>>
>> function(doc) {
>>   var today = new Date();
>>   var month = today.getMonth();
>>   var room, chatrooms = [];
>>   for ( room in doc.room ) {
>>       if ( doc.room[room].duration === 'seasonal' ||
>> doc.room[room].duration === 'ones' ) {
>>           if ( doc.room[room].start<  doc.room[room].end ) {
>>           if( doc.room[room].start<= month&&  doc.room[room].end>= month
>> ) {
>>                   chatrooms.push(doc.room[room])**;
>>               }
>>           }
>>           else {
>>           if( doc.room[room].start>= month&&  doc.room[room].end>= month
>> ) {
>>                   chatrooms.push(doc.room[room])**;
>>               }
>>           }
>>       }
>>       else {
>>           chatrooms.push(doc.room[room])**;
>>       }
>>
>>   }
>>   emit(doc._id, chatrooms);
>> }
>>
>> However, if I add this to the _design doc Futon will not save the document.
>> FF says: JSON.parse: bad control character in string literal.
>>
>> My _design doc looks like this:
>>
>> {
>>    "_id": "_design/chat-categories",
>>    "_rev": "9-**d5bca128d1fb98545691d78fa6aff9**bb",
>>    "views": {
>>        "categories": {
>>            "map": "function(doc) {
>>               var today = new Date();
>>              var month = today.getMonth();
>>               var room, chatrooms = [];
>>               for ( room in doc.room ) {
>>                       if ( doc.room[room].duration === \"seasonal\" ||
>> doc.room[room].duration === \"ones\" ) {
>>                           if ( doc.room[room].start<  doc.room[room].end ) {
>>                               if( doc.room[room].start<= month&&
>> doc.room[room].end>= month ) {
>>                                       chatrooms.push(doc.room[room])**;
>>                                   }
>>                           }
>>                           else {
>>                               if( doc.room[room].start>= month&&
>> doc.room[room].end>= month ) {
>>                                       chatrooms.push(doc.room[room])**;
>>                                   }
>>                           }
>>                       }
>>                       else {
>>                           chatrooms.push(doc.room[room])**;
>>                       }
>>                    }
>>               emit(doc._id, chatrooms);
>>         }"
>>         }
>>     }
>> }
>>
>> What do I miss?
>>
>> Thanks.
>>
>>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>

Re: _design doc issue

Posted by CGS <cg...@gmail.com>.
Use single quota ( ' ) instead of escape character and double quota.(\").
For some reasons I don't know, the JSON parser is no capable of
interpreting \" as it should.

CGS




On Fri, Jan 27, 2012 at 3:48 AM, Stephan Bardubitzki <
stephan@bardubitzki.com> wrote:

> I'm quite new to CouchDB and have to struggle with the following issue
> using Futon:
>
> In 'temporary view' this code does what I want to get out:
>
> function(doc) {
>  var today = new Date();
>  var month = today.getMonth();
>  var room, chatrooms = [];
>  for ( room in doc.room ) {
>      if ( doc.room[room].duration === 'seasonal' ||
> doc.room[room].duration === 'ones' ) {
>          if ( doc.room[room].start < doc.room[room].end ) {
>          if( doc.room[room].start <= month && doc.room[room].end >= month
> ) {
>                  chatrooms.push(doc.room[room])**;
>              }
>          }
>          else {
>          if( doc.room[room].start >= month && doc.room[room].end >= month
> ) {
>                  chatrooms.push(doc.room[room])**;
>              }
>          }
>      }
>      else {
>          chatrooms.push(doc.room[room])**;
>      }
>
>  }
>  emit(doc._id, chatrooms);
> }
>
> However, if I add this to the _design doc Futon will not save the document.
> FF says: JSON.parse: bad control character in string literal.
>
> My _design doc looks like this:
>
> {
>   "_id": "_design/chat-categories",
>   "_rev": "9-**d5bca128d1fb98545691d78fa6aff9**bb",
>   "views": {
>       "categories": {
>           "map": "function(doc) {
>              var today = new Date();
>             var month = today.getMonth();
>              var room, chatrooms = [];
>              for ( room in doc.room ) {
>                      if ( doc.room[room].duration === \"seasonal\" ||
> doc.room[room].duration === \"ones\" ) {
>                          if ( doc.room[room].start < doc.room[room].end ) {
>                              if( doc.room[room].start <= month &&
> doc.room[room].end >= month ) {
>                                      chatrooms.push(doc.room[room])**;
>                                  }
>                          }
>                          else {
>                              if( doc.room[room].start >= month &&
> doc.room[room].end >= month ) {
>                                      chatrooms.push(doc.room[room])**;
>                                  }
>                          }
>                      }
>                      else {
>                          chatrooms.push(doc.room[room])**;
>                      }
>                   }
>              emit(doc._id, chatrooms);
>        }"
>        }
>    }
> }
>
> What do I miss?
>
> Thanks.
>
>