You can't. Each document only knows about itself. But there is probably another way of accomplishing what you want with CouchDB.
On Wed, Apr 15, 2015 at 6:55 AM, ken tashiro <[email protected]> wrote: > Hi, > > I have a question. Suppose documents are > [ > { "_id": "11111" }, > { "_id": "22222", "ancestors": ["11111"], "value": "hello" }, > { "_id": "33333", "ancestors": ["22222","11111"], "value": "world" } > ] > like > > http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Linked_documents > and "include_docs=true". > > I want to make a map function like > function(doc) { > if (doc.ancestors) { > for (var i in doc.ancestors) { > if ( doc.value === 'world' AND ' value of ancestor is "hello" ' ) > { > emit (doc._id,ancestor's id); > } > } > } > } > and get {"key":"33333",value:"22222"}. > > My question is how can I use an included document and know > "value of ancestor" ? > > Thank you. > > ken tashiro >
