Skip to content

Instantly share code, notes, and snippets.

@jlank
Created July 4, 2012 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlank/3045404 to your computer and use it in GitHub Desktop.
Save jlank/3045404 to your computer and use it in GitHub Desktop.
CouchDB HTTP COPY for dscape/nano
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