couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Douglas Fils <f...@iastate.edu>
Subject find all unique field names
Date Thu, 28 May 2009 21:20:06 GMT
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


Mime
View raw message