Browse files

Add params support to insert_doc

  • Loading branch information...
1 parent 3f5ee88 commit d84b28fe5c07ee582d0f4084d9cec125f6b9242c @JayBeavers JayBeavers committed Aug 6, 2012
Showing with 18 additions and 7 deletions.
  1. +18 −7 nano.js
View
25 nano.js
@@ -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);
}

0 comments on commit d84b28f

Please sign in to comment.