On Sep 16, 2009, at 11:51 PM, Paul Davis wrote:
In Governator voice: "It's not a JOIN."
But you can use it if you have a doc like:
{"_id":"my-outline",
"other_docs":["docid,"other-docid"]
}
and then a view like
function(doc) {
for (var i=0; i < doc.other_docs.length; i++) {
emit([doc._id, i], {"_id" : doc.other_docs[i]}
};
}
So if I do,
emit(key, doc)
am I specifying the key value and overriding the default document to
be included since the value would contain _id and _rev members?
They'd have the same value, so it wouldn't be detectable, but still no
clear boundary between the value parts of the parameter and the
document part of the parameter.
I'm thinking it would be cleaner to support an optional 3 argument
to emit
with { _id:"", _rev:"" }? The current two argument emit() would be
the
equivalent of emit(key, value, { _id:doc._id, _rev:doc.rev}).
I think this is a pretty good idea. Though unless I'm missing
something the implementation difficulty rises noticeably. The only
initial drawback I see is how we explain the semantics of default
behavior. For ?include_docs=true it was simply "current version or
version specified by _rev". Obviously adding _id makes that weirder,
but I'm don't see a more clear explanation with the third parameter
version.
Paul Davis
A three parameter version would also allow like:
emit(key, value, null);
when you intentionally do not want any documents provided if the user
specifies include_docs=true.