CouchDB View - Filter by List Field Attribute (doc.objects.[0].attribute) -
i need create view lists values attribute of doc field.
sample doc:
{ "_id": "003e5a9742e04ce7a6791aa845405c17", "title", "testdoc", "samples": [ { "confidence": "high", "handle": "joetest" } ] }
example using doc, want view return values "handle"
i found example heading - contents of object specific attributes e.g. doc.objects.[0].attribute. when fill in attribute name, e.g. "handle" , replace doc.objects doc.samples, no results:
toggle line numbers // map function(doc) { (var idx in doc.objects) { emit(doc.objects[idx], attribute) } }
that create array of key-value-pairs key alway value of handle
. replace null
value want e.g. doc.title
. if want doc attached every row use query parameter ?include_docs=true
while requesting view.
// map function (doc) { var samples = doc.samples for(var = 0, sample; sample = samples[i++];) { emit(sample.handle, null) } }
Comments
Post a Comment