javascript - What does this sample map function in sample CouchDB Set mean? -


couchbase comes big db of beers. 2ms fetch time impressive don't understand following map function does:

function(doc, meta) {   switch(doc.type) {   case "brewery":     emit([meta.id]);     break;   case "beer":     if (doc.brewery_id) {       emit([doc.brewery_id, meta.id]);     }     break;   } } 

i can't wrap brain around it. meta thing coming from?

enter image description here

i can't wrap brain around it. meta thing coming from?

metadata supplemented couchbase server every stored document (json or binary). in view editor can see meta data in right pane of "preview random doc". example in screenshot question, meta.id "labbat_ontario_breweries_labbat_50" seen on right side.

meta.id actual key of document , present returned doc including views (even if not including key value explicitly view output) e.g. example view outputs doc.name, metadata still present returned row in view. can access meta.id element in json result.

function(doc, meta) {     emit(doc.name,null); } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -