incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <g...@pobox.com>
Subject Re: newbie question #1
Date Sun, 28 Dec 2008 16:22:03 GMT

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






Mime
View raw message