Created
July 4, 2012 04:46
-
-
Save jlank/3045404 to your computer and use it in GitHub Desktop.
CouchDB HTTP COPY for dscape/nano
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copy_doc(doc_src, doc_dest, opts, callback) { | |
if(typeof opts === "function") { | |
callback = opts; | |
opts = {}; | |
} | |
var params = { db: db_name, doc: doc_src, method: "COPY" | |
, headers: {"Destination": doc_dest} }; | |
head_doc(doc_dest, function (e,b,h) { | |
if (!e && opts.overwrite) { | |
params.headers["Destination"] += "?rev=" + h.etag.substring(1, h.etag.length - 1); | |
} | |
return relax(params, callback); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment