docs: function filterResults(r, keyFld, valueFld, keys) {//{{{
  
                      // Index by identifier:
                      var idx = {};
                      if (keyFld !== undefined) {
                          for (var i in r) idx[r[i][keyFld]] = r[i];
                      } else idx = r;
  
                      var out = {};
                      for (var k in idx) {
                          out[k] = {
                              // Pick for description:
                              label: valueFld
                                  ? valueFld
                                      .map(function(c){return idx[k][c];})
                                      .join(" - ")
                                      +" ("+k+")"
                                  : typeof idx[k] == "string"
                                      ? idx[k]+" ("+k+")"
                                      : idx[k][Object.keys(idx[k])[0]]
                              ,
                              // Pick for optional foreign keys:
                              keys: keys.map(function(fk){
                                  return [
                                      fk[0],        // Respect foreign field name.
                                      idx[k][fk[1]], // Replace requested value.
                                  ];
                              }),
                          };
                      };
                      return out;
                  }