I'm writing an application which uses CouchDB for its database. The application has similar qualities to the blog examples often used to illustrate Couchdb. There are "anchor" documents like posts which have other documents which refer to a particular post, like comments on a blog. (Each of the "comments" has a field which is like a sql foreign key. It contains the unique ID of the "post")
However, the "comments" documents are of various types, and one of those types makes the blog post no longer relevant to the application. (The blog "post" is a record of a medical treatment, the "comment" type which I am referring to is a report that indicates that the treatment has finished).
I am stuck trying to work out how to write a view which would emit a list of all the "posts" which do not have one of these treatment-finished documents ( like "comments" ) attached. Can anybody help me with this?
I can not just have an "active" field on the main "post" document, as there are multiple mobile clients which update this document, and I wish to avoid any revision conflicts if two of the clients were to modify the anchor document before coming back into network coverage.