I am wondering how to use CouchDB map / reduce with multiple parameters. For example, if I have teams that have players with age and gender, I assume that I will do this for my map function:
"function(doc){ if(doc.team_name) { emit(doc.team_name, doc); } }"
However, I am not sure how to write a reduction function to get the oldest male player on the team or the youngest woman or any other arbitrary request. Can I pass parameters in the url or do I need to write multiple views?
Thanks in advanceBen
. . , , , .
, emit [team, age]. .
emit
[team, age]
function(doc) { if (doc.team_name) { emit([doc.team_name, doc.age], doc); } }
. descending=true, . . , (- ) : startkey=[<team>, 999]&endkey=[<team>,0]&descending=true
descending=true
startkey=[<team>, 999]&endkey=[<team>,0]&descending=true
Source: https://habr.com/ru/post/1763495/More articles:Perl module to get all pages of a website? - scriptingC #: convert T to T [] - genericsvcs plugin for vim? - vimSubdomains and folders / directories - pythondefine select dropdown with jquery $ (this) - jqueryRedmine username - ruby-on-railsWhy is this C program giving unexpected results? - cEmbed HTML in jQuery - jqueryHow to efficiently read a large XML file consisting of a large number of small elements in Java? - javahow can I develop a trap test and a performance test for merging files in different version control systems? - version-controlAll Articles