Thursday, 19 September 2013

How to create a CouchDB View to join documents based on multiple, non-unique fields

How to create a CouchDB View to join documents based on multiple,
non-unique fields

I have a database with documents in the following forms:
{"Type" : "A", "Date": "2013-09-19", "Week" : "A", "Day" : "Mon"}
{"Type" : "B", "Week" : "A", "Day" : "Mon", "Class" : "xyz"}
How do I create a view that will list all the classes (from doc.Type =
"B") for a specific date (from doc.Type = "A")? Essentially it means
matching the "Week" and "Day" fields. I have found examples (mostly based
on Christopher Lenz's solution) but these are matching based on just one
field being matched, which is unique in one of the document types.

No comments:

Post a Comment