It would be bad design to do it place a potentially large series of hings like comments in one doc. I'm not sure what you're trying to solve but it would be trivially easy to use a view for this. Also if you wanted to do some special formatting of the json before it came back you could use a _list function to turn it into anything.
There are many approaches you can take..If a post has a 1 to many relationship with comment you can just include the post_id field in the each comment doc and make emit ([doc.post_id,doc.date_created],(<you could use include docs and leave this null or put the post text>) On Sun, Nov 10, 2013 at 1:34 PM, Keith Gable <[email protected]>wrote: > I don't know why you couldn't have many thousands of 3MB attachments. > For performance, I would make each comment a new document and fetch the > comments with a view and set include_docs to true. Putting all of the > comments in a thread into one document works, but it is not going to > work well when the scale of comments increases because you will have > conflicts. From: Mark Deibert > Sent: 11/10/2013 15:17 > To: [email protected] > Subject: Re: Storage limitations? > So Couch will not handle lots (I hope many thousands eventually) of 3MB > photo attachments? This really stinks. So now I need to bring back a PHP > server script to support my Couchapp? > > > On Sun, Nov 10, 2013 at 4:10 PM, Mark Deibert <[email protected] > >wrote: > > > Each comment is normally a very small amount of information, and id, > > userName, a date and a small text field. Probably no more than a short > > sentence on average. Why do I need to go through the trouble of creating > > new comment docs for each? This totally complicates the comment read code > > (there will 1000 reads to every 1 write, at least) both in the UI and the > > db for no reason. > > > > > > On Sun, Nov 10, 2013 at 1:34 PM, Jens Alfke <[email protected]> wrote: > > > >> > >> On Nov 9, 2013, at 11:47 AM, Robert Newson <[email protected]<mailto: > >> [email protected]>> wrote: > >> > >> attachments are different to documents. They're stored as a series of > >> binary chunks and so they can be streamed in and out, you can go large > >> with attachments. > >> > >> But on the other hand, all attachments will get copied during a database > >> compaction, so they slow down the process and require more free disk > space. > >> If you have many gigabytes of attachments, you might consider storing > them > >> externally and putting URL links in the documents. > >> > >> As for comments, just add new documents for each comment and use a > >> view (https://wiki.apache.org/couchdb/HTTP_view_API, > >> https://wiki.apache.org/couchdb/View_collation) to bring the article > >> and comment thread together. No need to update a document that way. > >> > >> Yup. The guide <guide.couchdb.org<http://guide.couchdb.org>> has a > >> chapter-long example of a blog application that shows how to do comments > >> this way. > >> > >> —Jens > >> > > > > >
