Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
Add params support to insert_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBeavers committed Aug 6, 2012
1 parent 3f5ee88 commit d84b28f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions nano.js
Expand Up @@ -561,19 +561,30 @@ module.exports = exports = nano = function database_module(cfg) {
*
* @param {doc:object|string} document body
* @param {doc_name:string:optional} document name
* @param {params:string:optional} additions to the querystring
*
* @see relax
*/
function insert_doc(doc,doc_name,callback) {
function insert_doc(doc,doc_name,params,callback) {
var opts = {db: db_name, body: doc, method: "POST"};
if(doc_name) {
if(typeof doc_name === "function") {

if (!callback) {
if (params && typeof params === "function") {
callback = params;
params = null;
} else if (doc_name && typeof doc_name === "function") {
callback = doc_name;
doc_name = null;
}
else {
opts.doc = doc_name;
opts.method = "PUT";
}
}

if (params) {
opts.params = params;
}

if(doc_name) {
opts.doc = doc_name;
opts.method = "PUT";
}
return relax(opts,callback);
}
Expand Down

0 comments on commit d84b28f

Please sign in to comment.