couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <paul.joseph.da...@gmail.com>
Subject Re: newbie question #1
Date Sun, 28 Dec 2008 15:10:20 GMT
On Sun, Dec 28, 2008 at 9:50 AM, Geir Magnusson Jr. <geir@pobox.com> 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 :)
>

I think the stumbling block here is that we're using two different
definitions of 'document'. You appear to consider the user data a
document where as CouchDB terminology refers to the entire JSON object
as the document. Thus if for the sake of your application, document
referred to the 'user document' as the data stored under a specific
element, the whole issue goes away.

>>
>> This doesn't just apply to _id and _rev, there are other meta fields that
>> can be returned in a doc, and those will also have underscores. The rule is
>> reserved fields in document root start with underscore. User fields at the
>> doc root level cannot start with underscore.
>
> Yep - that was clear in the docs.
>
> geir
>
>

Mime
View raw message