couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Douglas Fils <>
Subject post design documents
Date Tue, 02 Jun 2009 14:23:25 GMT
  So I was looking at the "View Snippets" page (ref: and noted the curl 
command.  I am using something similar but rather than on the command 
line I place the map reduce code in a file.  So if I take the code 
Brian, sent me this morning and put it in a file in a manner like I have 
appended to the end of this email I can use something like:

 curl -s -i -X POST -H 'Content-Type: application/json' --data 

rather than needing to place the .js in the command line argument 

  The question is...  I've tried some combinations, but can't seem to 
get an approach that would allow me to post the map reduce code to a 
_design document rather than just a _temp_view as in this example.

  Is it possible, once you have a map reduce code you like and tested 
against a small test data set to then POST it via curl for example, 
against the production database or do you have to place the design 
documents in via the gui?


Thanks again to Brian, Chris and Blair for your help on that "find 
unique fields..." thread

-------- start file--------
 "function(doc) {
  for (var key in doc) {
 "function(ks, vs, co) {
  if (co) {
    var result = vs.shift();
    for (var i in vs) {
      for (var j in vs[i]) {
        result[j] = (result[j] || 0) + vs[i][j];
    return result;
  } else {
    var result = {};
    for (var i in ks) {
      var key = ks[i];
      result[key[0]] = (result[key[0]] || 0) + 1;
    return result;
--------- end file --------

View raw message