Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reference other documents in a couchDB view (joining like functionality)
    primarykey
    data
    text
    <p>We have a CouchDB representation of an XML database which we use to power a javascript based front-end for manipulating the XML documents. The basic structure is a simple 3 level hierarchy. i.e.</p> <p>A -> B -> C</p> <p>A: Parent document (type A) B: any number of child documents of parent type A C: any number of child documents of parent type B</p> <p>We represent these 3 document types in CouchDB with a <code>type</code> attribute:</p> <p>e.g. </p> <pre><code>{ "_id":"llgc-id:433", "_rev":"1-3760f3e01d7752a7508b047e0d094301", "type":"A", "label":"Top Level A document", "logicalMap":{ "issues":{ "1":{ "URL":"http://hdl.handle.net/10107/434-0", "FILE":"llgc-id:434" }, "2":{ "URL":"http://hdl.handle.net/10107/467-0", "FILE":"llgc-id:467" etc... } } } } { "_id":"llgc-id:433", "_rev":"1-3760f3e01d7752a7508b047e0d094301", "type":"B", "label":"a B document", } </code></pre> <p>What I want to do is produce a view which returns documents just like the A type but includes the label attribute from the B document within the logicalMap list e.g.</p> <pre><code>{ "_id":"llgc-id:433", "_rev":"1-3760f3e01d7752a7508b047e0d094301", "type":"A", "label":"Top Level A document", "logicalMap":{ "issues":{ "1":{ "URL":"http://hdl.handle.net/10107/434-0", "FILE":"llgc-id:434", "LABEL":"a B document" }, "2":{ "URL":"http://hdl.handle.net/10107/467-0", "FILE":"llgc-id:467", "LABEL":"another B document" etc... } } } } </code></pre> <p>I'm struggling to get my head around the best way to perform this. It looks like it should be fairly simple though! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload