couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Troy Martin <>
Subject View collation question
Date Fri, 29 Mar 2013 17:56:02 GMT
I'm currently associating user documents with group documents like this:

   "_id": "544f4718732b51506d9de60a4e000505",
   "_rev": "137-f99f9a4aa5e3a4d48b76d98200b1f4fa",
   "username": "spencer",
   "firstName": "Spencer",
   "lastName": "jones",
   "emailAddress": "",
   "roles": [
   "type": "user",
   "disabled": false,
   "empId": "10"

   "_id": "3979684300c58a4c90c7c6e0d6035260",
   "_rev": "58-0df6c24716cd1768f668399a96059692",
   "type": "group",
   "name": "marina",
   "description": "",
   "users": [

When I want to edit a user my app fetches the user document and a list of all the groups in
the system. It then loops through the groups and pulls out the ones the user is associated
with by looping through the users array looking for the users _id number. That's a lot of
looping…8-) I have to have a list of groups anyway so the user can select from them, but
I'm wondering if I can use view collation to fetch the user and their associated groups in
one request to increase efficiency? I've looked at some examples on view collation, but the
ones I've seen show a one to one relationship between documents. Not sure if I can use it
with my data structured this way. I've considered a joining document like a joining table
from sql, but thought I'd see if there was a way to make this work as is.



View raw message