From user-return-2401-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun Dec 28 16:22:41 2008 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 18663 invoked from network); 28 Dec 2008 16:22:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Dec 2008 16:22:41 -0000 Received: (qmail 50541 invoked by uid 500); 28 Dec 2008 16:22:40 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 50501 invoked by uid 500); 28 Dec 2008 16:22:39 -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 50490 invoked by uid 99); 28 Dec 2008 16:22:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Dec 2008 08:22:39 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 216.86.168.178 is neither permitted nor denied by domain of geir@pobox.com) Received: from [216.86.168.178] (HELO mxout-03.mxes.net) (216.86.168.178) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Dec 2008 16:22:31 +0000 Received: from [10.0.1.194] (unknown [67.86.14.166]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTPSA id 9CC2823E3AA for ; Sun, 28 Dec 2008 11:22:04 -0500 (EST) Message-Id: <9EB38E5C-41B2-46CE-80DC-136280E6D818@pobox.com> From: "Geir Magnusson Jr." To: user@couchdb.apache.org In-Reply-To: <28782D92-52B6-4CAD-B9C2-41655C236080@apache.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: newbie question #1 Date: Sun, 28 Dec 2008 11:22:03 -0500 References: <98979283-BB61-4D15-AF05-196979FA42BC@pobox.com> <20081228131927.GO21261@tumbolia.org> <13A776CD-4E7F-48D4-A204-B6FECE50F291@pobox.com> <60C9F0D4-9C91-4F50-B8CE-278C390533B0@pobox.com> <28782D92-52B6-4CAD-B9C2-41655C236080@apache.org> X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org On Dec 28, 2008, at 10:54 AM, Damien Katz wrote: > > On Dec 28, 2008, at 9:50 AM, Geir Magnusson Jr. wrote: > >> >> On Dec 28, 2008, at 9:36 AM, Damien Katz wrote: >> >>> >>> On Dec 28, 2008, at 8:58 AM, Geir Magnusson Jr. wrote: >>> >>>> >>>> The following two documents are legal JSON documents, but CouchDB >>>> can't store them (if I grok CouchDB right) : >>>> >>>> { >>>> "_id" : "geir's document", >>>> "foo" : "bar" >>>> } >>>> >>>> { >>>> "_id" : "geir's document", >>>> "foo" : "woogie" >>>> } >>> >>> Sure you can: >>> >>> {_id:"the actual id", >>> body:{ >>> "_id" : "geir's document", >>> "foo" : "bar" >>> } >>> } >>> >>> >>> If you need to store underscore fields, store move the whole >>> document down from the top level into another field. >> >> I understand that, but that's really my point - I need to change my >> document if I want to store it in CouchDB. People don't seem to >> care though :) > > You don't need to change it, but you might need to wrapper it. This > is like complaining that you can't mail someone a postcard that > contains in the message the address of someone other than the > recipient. If you have that problem, then put it in an envelope. I respectfully disagree - I don't think that's an appropriate analogy at all. I think it's more like saying you can send a postcard to anyone except people whose names start with "R", and if you want to do that, you have to put the postcard in a special envelope. By restricting the JSON keyspace of the user document, you're saying that if they have a document that happens to have a field that starts with "_", the user needs to do special handling of it. From my POV, to produce a general API that can persist all legal JSON documents that the API user might pass me, I'd just store *every* document in an envelope to be safe and keep my codepaths clean and devoid of special handling (and later maintenance, e.g. if you decide that "$" should be a special starting character as well...). Now, if I have to do this client side the documents that are stored API specific, which leads me to the conclusion that the DB should be storing them this way for maximum interop. My US$0.02, and I am completely comfortable with the fact that I'm a singleton minority on this :) geir