Hi,
I am just starting to play with CouchDB and I read a lot of blog posts,
apache's wiki pages and the published pages of the upcoming book. So far
it feels weird (always worked with relational databases), but I am
learning fast I think.
I have a question I could't find an answer to, I hope it doesn't sound
too dumb ;-)
Let's say I have this database, I have an id, a title, a slug and a
body. If I GET /database/id it works just fine, however I'd like to be
able to GET /database/slug as well. How do I go for it?
I realize I could set an arbitrary "id", so that I could GET
/database/sometext and pretend it was the slug while I am actually
calling an id, but I'd like to be able to do both.
I also know I could create a view like this:
function(doc) {
if(doc.slug) {
emit(doc.slug, null);
}
}
to get all the items with a given slug (GET
/database/_view/posts/by_slug/?key="sometext"), but the slug is going to
be a unique string, so it seems a superflous method. By the way: why do
I have to pass quotes to the key value? Am I doing something wrong with
this view?
So: is there any way for me to GET /database/slug in addition to GET
/database/id ?
Thanks,
Andreas