I’m working on a to do list with a simple collaboration feature.
Basically a user says that he wants to share a group of todo items.
The structure is that a item belongs to a group and that group is available to a set of users.
Now to get the list of todo items for a specific user, I need to figure out all items in groups the user has access too.
So basically the structure looks somewhat like this:
user – group – item
What i want is given a user id I want the items for all the groups the user has access to.
From my early experiments it seems to be somewhat problematic to produce a view with the desired output.
Is CouchDB a good fit, or should I be looking for another database to work with?
If I understand it correctly, each group has a list of users and a list of items. Then, for each group, you can emit a row for each (user, item) pair:
Querying the view with
key="userId", should give the correct result.For example, if a group document has the following structure:
Your map function can be something like (not tested!!!):
If you query it with
key="User_1"&include_docs=trueit should return all items in the groups of the user with_id=="User_1".