Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A75DC925B for ; Fri, 27 Jan 2012 04:08:48 +0000 (UTC) Received: (qmail 63107 invoked by uid 500); 27 Jan 2012 04:08:45 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 62693 invoked by uid 500); 27 Jan 2012 04:08:36 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 62669 invoked by uid 99); 27 Jan 2012 04:08:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 04:08:32 +0000 X-ASF-Spam-Status: No, hits=2.6 required=5.0 tests=FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cgsmcmlxxv@gmail.com designates 209.85.216.52 as permitted sender) Received: from [209.85.216.52] (HELO mail-qw0-f52.google.com) (209.85.216.52) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 04:08:27 +0000 Received: by qafi31 with SMTP id i31so775353qaf.11 for ; Thu, 26 Jan 2012 20:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=94h456OTmjNjVtsvujJzKVSdrWzEsXXGDXlfMYga+EM=; b=IeblJtylfbpVC7cbYv7v5NrrpDJfRt3rLDuZiI0SjX4KDTFEXmRCAlrvygHAE80egQ iTHQ41yyDDLEUPBD8Jz1Olmv4rnYm7jdOj1wwD8KRfK3DfmcI3TrFh5bddsS3tJpyAs+ cO1j193fD3GNnLQMvDpEZAQ8kJP2y44PNp14U= MIME-Version: 1.0 Received: by 10.224.96.84 with SMTP id g20mr6086927qan.17.1327637286311; Thu, 26 Jan 2012 20:08:06 -0800 (PST) Received: by 10.229.83.197 with HTTP; Thu, 26 Jan 2012 20:08:06 -0800 (PST) In-Reply-To: <4F22108B.6040302@bardubitzki.com> References: <4F22108B.6040302@bardubitzki.com> Date: Fri, 27 Jan 2012 05:08:06 +0100 Message-ID: Subject: Re: _design doc issue From: CGS To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=20cf3063e33bd754d104b77aa469 --20cf3063e33bd754d104b77aa469 Content-Type: text/plain; charset=ISO-8859-1 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. > > --20cf3063e33bd754d104b77aa469--