incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Alfke <>
Subject Re: couchdb data structure
Date Fri, 22 Nov 2013 16:58:31 GMT

On Nov 22, 2013, at 6:18 AM, John Norris <> wrote:

> To continue on this path, so if I have separate document types, where docTypeA has a
reference to docTypeB, can I have a view that returns a docTypeA based on a value within docTypeB

I think you can do this using the linked-documents feature of the indexer. If your map function
emits a value that’s an object containing a “_id” property, then the view will treat
that index entry as though it were generated by the document with that ID, so if you query
with include_docs the contents of the linked document will be returned.

> Also, my view returns a list of key, values. And I can use the eg key parameter to return
a particular key, value. I can also use the keys parameter to return more than one particular
key. But can I return a document based on more than one field.

Sure. In your example, the map function just has to do
	emit(doc.fname, null);
	emit(doc.lname, null);
So now both the first and last names are in the index, so view queries will find both first
and last names matching your key.

View raw message