couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Troy Kruthoff <>
Subject Re: Suggestions required on app design
Date Wed, 04 Mar 2009 18:10:37 GMT

On Mar 4, 2009, at 9:34 AM, Ramkrishna Kulkarni wrote:

> Hello All,
> Please bear with me, I'm new. I have been playing with CouchDB
> recently and I find it kool! I would appreciate if someone from the
> list could answer few of my questions below.
> Consider I have a database-per-user design and I want to be RESTful.
> a) How do I list all users by just typing a URL like http://server/users/?

There is a built-in view http://host:5984/_all_dbs

> b) Is there a way to specify startkey and endkey while listing such
> databases? For example: I want to list only databases of users
> starting with "a"

I believe the _all_dbs view can be filtered just like any other view  
(see query options

> I know this is possible if there is sinlge "users" database with a
> document for each user with _id=user-id.
> Further, consider I have database-per-blog as well (assume this is a
> simple blog application).
> a) How do I create something like view (views I believe cannot be run
> across databases) so that whenever a user resource is requested, I
> return all blogs written by that user in addition to user information?
> Basically links to all blog resources.
> Probably this logic should be in the application. Fire two queries,
> one to get user data and another to get blogs?

Your on the right track.  In the users database you can store the name  
of the blog databases.

> The reason I'm trying to do this is because I'm bit scared about
> having data in just couple of huge files. I would rather have data
> spread out in several smaller files.
> Probably there are better ways to do this. Please let me know.
> Thanks,
> Ram

View raw message