Thanks, Jan. I tried that, but it produced three separate documents. I
was hoping to get everything in a single document.

On Fri, Dec 16, 2016, at 02:10 AM, Jan Lehnardt wrote:
> 
> > On 15 Dec 2016, at 20:56, David Squier <[email protected]> wrote:
> > 
> > Greetings,
> > 
> > 
> > 
> > I have a master document that contains multiple references to child
> > documents. I want to use the Linked Documents feature to "compose" a
> > master document that replaces all the child document references (i.e.,
> > keys) with the actual document contents.
> > 
> > 
> > I can do this with a single linked document using the following emit
> > in a view:
> > 
> > 
> > emit(doc._id, { _id: "child_document_1" });
> 
> Assuming:
> 
> {
>   _id: “main_doc”,
>   "child_documents”: [
>     "child_doc_id_1”,
>     "child_doc_id_2”,
>     "child_doc_id_3”
>   ]
> 
> }
> 
> then
> 
> function(doc) {
>   doc.child_documents.forEach(function(child_doc) {
>     emit(doc._id, { _id: child_doc._id})
>   })
> }
> 
> will do the trick.
> 
> Best
> Jan
> --
> 
> 
> > 
> > 
> > 
> > With the include_docs=true, this populates the document contents for
> > child_document_1 as expected. However, I have not found a way do this
> > for multiple documents.
> > 
> > 
> > For example, I'd like to do something like the following:
> > 
> > 
> > 
> > emit(doc._id, "children": { _id: "child_document_1", _id:
> > "child_document_2" });
> > 
> > 
> > And have both child documents replaced with their document bodies._id.
> > However, it appears the Linked Documents syntax is specific in wanting a
> > single document referenced and therefore only allowing that documents
> > contents to be populated.
> > 
> > 
> > Is this even possible? If not through Views, through some other
> > mechanism?
> > 
> > 
> > NOTE: I do not want to generate multiple documents (i.e., use multiple 
> > emit() statements) as my goal is to return a single document.
> > 
> > 
> > Thanks much!
> > 
> > 
> 
> -- 
> Professional Support for Apache CouchDB:
> https://neighbourhood.ie/couchdb-support/
> 

Reply via email to