couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Bangert <>
Subject Associating users and comments
Date Wed, 01 Oct 2008 02:10:21 GMT
I have a setup similar to what Chris Lenz documented with comments and  
posts that they go to. However, since user data changes, I'd like to  
figure out a way to get back the user record either before or after  
the comment they made rather than having the relevant user data inside  
every comment posted (which would require a ton of updates should the  
user info change).

So given a database with types of post, comment, user, how would I get  
back a few posts, with their comments, and with the comment posters  
full name (which is in a separate document)?

Also, with regards to the originally documented trick to return both  
custom and order documents:

function(doc) {
   if (doc.Type == "customer") {
     emit([doc._id, 0], doc);
   } else if (doc.Type == "order") {
     emit([doc.customer_id, 1], doc);

 From my understanding, imposing a count limit on this doesn't  
discriminate between customers or orders, just total rows returned  
from the view. So how would I say, give me back 5 customers with their  
orders? Or even, give me back 10 customers with their last 5 orders?

View raw message