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 A1319985D for ; Fri, 27 Jan 2012 02:49:18 +0000 (UTC) Received: (qmail 98223 invoked by uid 500); 27 Jan 2012 02:49:16 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 97916 invoked by uid 500); 27 Jan 2012 02:49:14 -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 97845 invoked by uid 99); 27 Jan 2012 02:49:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 02:49:12 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [198.235.201.17] (HELO barracuda.northwestel.ca) (198.235.201.17) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 02:49:03 +0000 X-ASG-Debug-ID: 1327632518-04700c575312760001-z14J5S Received: from [192.168.1.102] ([199.247.191.174]) by barracuda.northwestel.ca with ESMTP id 8BwPlqsWCBx95rOv for ; Thu, 26 Jan 2012 18:48:38 -0800 (PST) X-Barracuda-Envelope-From: stephan@bardubitzki.com X-Barracuda-Apparent-Source-IP: 199.247.191.174 Message-ID: <4F22108B.6040302@bardubitzki.com> Date: Thu, 26 Jan 2012 18:48:43 -0800 From: Stephan Bardubitzki User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111229 Thunderbird/9.0 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: _design doc issue Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-ASG-Orig-Subj: _design doc issue Content-Transfer-Encoding: 7bit X-Barracuda-Connect: UNKNOWN[199.247.191.174] X-Barracuda-Start-Time: 1327632518 X-Barracuda-URL: http://198.235.201.17:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at northwestel.ca X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=6.8 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.86797 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Virus-Checked: Checked by ClamAV on apache.org 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.