Hey,
I am managing a database that has hundreds of thousands of documents (so far),
all containing a field called "keyword_id". I am not storing the "keyword_name"
inside of each individual document for several reasons. The biggest reason
being that the name could change at any time, but I don't want old documents to
become outdated. I still want them to be associated with one another.
Anyway, I am wondering if there is currently a special function within the
CouchDB JavaScript view server to pull data across views. I have a view that
serves as an index of keyword_ids/names. I also have another view that
aggregates keyword data, but can't return the keyword names. Currently, I just
run two requests to CouchDB. One to retrieve all aggregated keyword data, and
another to retrieve the relevant keyword names as they relate to the ids.
I am assuming that the way I am doing it is currently the best way, but wanted
to see if it was possible to run something like:
function(doc) {
var keyword_name =
view("/lu_persistence/_design/keywords/_view/keyword_id_name_map?key=" +
doc.keyword_id);
doc.keyword_name = keyword_name;
emit(null, doc);
}
Maybe I'm just nuts, but I think this would be ridiculously useful. And if it's
already in there, and someone could point me in the right direction, I'd
greatly appreciate it.
Thanks a million,
Mike Keen