couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: Handling unique URL friendly identifiers
Date Thu, 31 Dec 2009 17:25:33 GMT
On Thu, Dec 31, 2009 at 12:28 AM, Bernd Lutz <iberndlu@googlemail.com> wrote:
>>
>> I think it's actually good practice to use docids for friendly identifiers. Then
collisions between URL slugs will appear as couchdb conflicts (eventually, in the case of
distributed app, and immediately, in the case of a single node or partitioned cluster).
>>
>
> At first I thought this, too. But this would mean documents have to be deleted and then
re added for updates. _ids used to realize a sort of relation have to be changed, too - like
comments in a blog. So I thought it might be better to avoid further problems by not using
url friendly identifiers as _ids.

I've been happy enough to live without changeable ids. I've even done
embarrassing stuff like misspelled a word in a blog post title, which
I then fixed in doc.title, but it is still wrong in doc._id (and thus
the URL). Details like this I suppose are a matter of how much the
business case can be bent around the technology, and vice versa.

Also, bear in mind that 99% of the time (in apps which don't do a
whole lot of disconnected operation) when there is an _id collision it
will manifest itself before the document is saved anywhere.

If you are building a truly p2p app where no single entity will be in
control of the "real" state of the data, then you might be better off
using uuids. (But then you'd better resign yourself to not having
uniqueness constraints of any sort...)

>
> But I see the point: Better error handling. Additionally it might be useful to add a
prefix to distinguish between content types and being able to have the same identifiers for
different content types.
>

Yes, a prefix is sensible in most cases.

Chris



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Mime
View raw message