creationix / couch-client

A minimal CouchDB client that easy and powerful
MIT License
101 stars 9 forks source link

The request method should allow functions in body to be able to save design docs correctly #24

Open anton-107 opened 13 years ago

anton-107 commented 13 years ago

Example request: databaseClient.request("PUT", designName, designDoc, function(err, data) {} );

Design doc contains functions and they are cut off internally by JSON.stringify. Please, enhance this line:

body = JSON.stringify(body)

with this snippet:

body = JSON.stringify(body, function(key, val) {
  if (typeof val == 'function') {
    return val.toString();
  }
  return val;
});