On Fri, May 29, 2009 at 9:20 AM, Douglas Fils <[email protected]> wrote:
> Forgive the noob question..  but I've not been able to easily locate an
> approach today to getting a return that gives all the unique field names in
> a couch database.
>
> It's not too hard to generate a map function that emits an array of the
> field names in a particular record....
> (please note this is about as much JS as I have ever written)  :)
> function(doc) {
>  var i = 0;
>  var keyNames = new Array();
>  for (var key in doc) {
>    keyNames[i] = key
>    i++;
>  }
>  emit(null,keyNames);
> }
>
> However, once I pass that over to the reduce (assuming this is even the way
> to do it) I don't see an easy way to get the unique intersection of the
> various field names.
>
> Any help would be appreciated...
> Thanks
> Doug
>
>

maybe the map should be

function(doc) {
 for (var key in doc) {
   emit(key,"")
 }
}

and the reduce
function(keys,values) {
  return null;
}

and just use the returned keys as the field names.

--- Blair

Reply via email to