diff --git a/lib/couchdb.js b/lib/couchdb.js index 0005126..a8eb565 100644 --- a/lib/couchdb.js +++ b/lib/couchdb.js @@ -428,7 +428,8 @@ Database.prototype.getAttachmentResponse = function(doc, attachmentName){ Database.prototype.saveDoc = function(doc, opts) { var self = this , method = httpMethod.PUT - , path = "/"; + , path = "/" + , buf; return Q.when(doc, function(doc) { if (doc._id === undefined) { @@ -448,12 +449,14 @@ Database.prototype.saveDoc = function(doc, opts) { opts = { bulk : true }; } } + + buf = new Buffer(JSON.stringify(doc), 'utf-8'); return self.request({ appendName: (opts && opts.bulk) ? "/_bulk_docs" : "", // Define factor appended to DB name. method: method, pathname: path, - body: typeof doc === "string" ? [doc] : [JSON.stringify(doc)] + body: typeof doc === "string" ? [doc] : buf }); }); };