Geir Magnusson Jr. schrieb:
I work for a company (10gen) that's making what I refer to as a
"document oriented" database (called MongoDB*), and I've long been
meaning to grok CouchDB. Now that I have some time during the year-end
hibernation, I figured this is a good time to dig in.
So I have some basic questions. Warning - these are really basic, and
could be caused entirely by my current lack of caffination. I assume
the best place to find docs is the wiki. If there's something better,
any pointers welcome.
First newbie question :
Looking at http://wiki.apache.org/couchdb/HTTP_Document_API, I
understand that _id and _rev are reserved fields in the document**.
Now, looking at the _all_docs example, I see I get back a list of docs :
{
"total_rows": 3, "offset": 0, "rows": [
{"id": "doc1", "key": "doc1", "value": {"rev": "4324BB"}},
{"id": "doc2", "key": "doc2", "value": {"rev":"2441HF"}},
{"id": "doc3", "key": "doc3", "value": {"rev":"74EC24"}}
]
}
what is "id"? is that supposed to be "_id"?
What you are looking at here is a view result, which is not the same as
the document.
Documents have "_id" and "_rev" fields, views have "id" and "ref" fields
that point to the document with the given field values.
If you want to query the documents, too, you have to use the
include_docs=true option, in which case every row of your view result
has a "doc" attribute that contains the original document.
I think it was a good choice to have different names here.
what is "key"? [...]
"key" and "value" contain the key and value that were used in the emit
function call that added the entry.
[...] I think that by reserving fields like this,
you can't claim to be storing JSON anymore, but "JSON--" or "almost
JSON".
I would see that as a reasonable compromise..