couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Smith (JIRA)" <>
Subject [jira] [Commented] (COUCHDB-1222) Naming convention: _id/_rev and id/rev
Date Thu, 14 Jul 2011 13:07:03 GMT


Jason Smith commented on COUCHDB-1222:

To quote a brilliant quotation of a brilliant dialogue:
"The name of the song is called 'Haddocks' Eyes.'"
"Oh, that's the name of the song is it?" Alice said trying to feel interested.
"No. You don't understand," the Knight said, looking a little vexed. "That's what the name
is *called*. The name really *is* 'The Aged Aged Man.'"
"Then I ought to have said 'That's what the *song* is called'?" Alice corrected herself.
"No, you oughtn't: that's quite another thing! The *song* is called 'Ways and Means': but
that's only what it's *called*, you know!"
"Well, what *is* the song, then?" said Alice, who was by this time completely bewildered.
"I was coming to that," the Knight said. "The song really *is* 'A-sitting On A Gate': and
the tune's my own invention."

- Lewis Carroll, _Through the Looking Glass_
Originally quoted in Peter van der Linden's classic _Expert C Programming: Deep C Secrets_
(orange book, blue fish)

They really *are* the "id" and the "rev". For some updates (_bulk_docs, PUT, POST), CouchDB
will tell you, "The id is this, and the rev is that."

Inside a document, you can use any field name you want, including "id" and "rev". CouchDB's
special fields must start with underscore. Thus, inside a document, the id and rev are *called*
"_id" and "_rev" respectively.

To answer your immediate problem, if CouchDB returns "id" and "rev" you should *not* make
a model out of that data because that is in fact *metadata* about the document. I think that
is why there was never long-term pressure to make it consistent. (Also, IMHO, the "is" vs.
"called" distinction does make sense, even if it confuses the development process a bit.)

> Naming convention: _id/_rev and id/rev
> --------------------------------------
>                 Key: COUCHDB-1222
>                 URL:
>             Project: CouchDB
>          Issue Type: Improvement
>            Reporter: Johnny Weng Luu
>            Priority: Minor
> I'm using a MVC framework to communicate with CouchDB.
> Sometimes CouchDB returns _id/_rev and other times id/rev.
> Could either one of them be used instead, cause the model layer usually have pre set
fields that can't be changed.
> And this would also not confuse developers when they are parsing the result.

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message