couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <>
Subject Re: Update handler doc ids
Date Mon, 15 Nov 2010 15:11:25 GMT
> Thanks, got it working. This is good stuff.

Your welcome! Sorry, for the delayed response.

> Hmm, I don't follow. I have a doc for user foobar with "_id:foobar".
> If I had a second type of document, say one type with user's blog
> posts and another with comments by same user, then do you mean I'd
> need to add a field unique to usernames because the ID has already
> been used?

I'm saying that if you're going to use a natural key as the ID of a
document that you should namespace it. Like so:

{ "_id": "user:foo", "type": "user", "full_name": "Foo Baz Barington" }

That way, you can also have another kind of document, in a different
ID namespace, with the same natural key value. So, for instance, their
could be a book called Foo:

{ "_id": "book:foo", "type": "book", "title": "Foo" }

And their IDs wont collide.

View raw message