Skip to content
This repository
Browse code

Add params support to insert_doc

  • Loading branch information...
commit d84b28fe5c07ee582d0f4084d9cec125f6b9242c 1 parent 3f5ee88
Jay Beavers JayBeavers authored

Showing 1 changed file with 18 additions and 7 deletions. Show diff stats Hide diff stats

  1. +18 7 nano.js
25 nano.js
@@ -561,19 +561,30 @@ module.exports = exports = nano = function database_module(cfg) {
561 561 *
562 562 * @param {doc:object|string} document body
563 563 * @param {doc_name:string:optional} document name
  564 + * @param {params:string:optional} additions to the querystring
564 565 *
565 566 * @see relax
566 567 */
567   - function insert_doc(doc,doc_name,callback) {
  568 + function insert_doc(doc,doc_name,params,callback) {
568 569 var opts = {db: db_name, body: doc, method: "POST"};
569   - if(doc_name) {
570   - if(typeof doc_name === "function") {
  570 +
  571 + if (!callback) {
  572 + if (params && typeof params === "function") {
  573 + callback = params;
  574 + params = null;
  575 + } else if (doc_name && typeof doc_name === "function") {
571 576 callback = doc_name;
  577 + doc_name = null;
572 578 }
573   - else {
574   - opts.doc = doc_name;
575   - opts.method = "PUT";
576   - }
  579 + }
  580 +
  581 + if (params) {
  582 + opts.params = params;
  583 + }
  584 +
  585 + if(doc_name) {
  586 + opts.doc = doc_name;
  587 + opts.method = "PUT";
577 588 }
578 589 return relax(opts,callback);
579 590 }

0 comments on commit d84b28f

Please sign in to comment.
Something went wrong with that request. Please try again.