couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CGS <cgsmcml...@gmail.com>
Subject Re: _design doc issue
Date Fri, 27 Jan 2012 04:35:36 GMT
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
>>
>>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message