emitting whole doc

In lots of places i've read that u should not emit whole doc in view for example

emit(doc.email, doc) 

and to instead use include_docs=true, but then i come across this
http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-debug...
"The only way to ensure full consistency here is to include the documents themselves in the values emitted by the map function."
So, what's true?

1 Answer

« Back to question.

Hello,

As you can see in the documentation chapter you are pointing, this is a "debug chapter", this means this is here to help your understand behavior when things are not working as expected.

The best practise is really: do not emit the document!

If you do that, all your database will be copy in the index, wasting lot of place for almost no benefits.

it is better to emit the key you need, some value of needed, and then use the document ID from your application to get the full document. You may have some kind of inconsistency but this is most of the time a corner case, since you can control this with the "durability constraints" (PersistTo.Master) and query stale option (stale=false)

Regards
Tug
@tgrall