@@ -464,15 +464,15 @@ Base.prototype._meta = function (doc) {
464
464
* Parse arguments.
465
465
*
466
466
* @param {Array } args The arguments.
467
- * @param {Integer } start The index from which to start reading arguments.
468
- * @param {Boolean } withDoc Set to `true` if the doc source is given as a
467
+ * @param {Integer } [ start] The index from which to start reading arguments.
468
+ * @param {Boolean } [withBody] Set to `true` if the request body is given as a
469
469
* parameter before HTTP query options.
470
- * @return { Promise } A Promise, if no callback is provided,
471
- * otherwise `null`.
470
+ * @param { Boolean } [notDoc] The request body is not a document.
471
+ * @return { Promise } A Promise, if no callback is provided, otherwise `null`.
472
472
* @private
473
473
*/
474
474
475
- Base . prototype . _ = function ( args , start , withDoc ) {
475
+ Base . prototype . _ = function ( args , start , withBody , notDoc ) {
476
476
var self = this , doc , id , rev ;
477
477
478
478
function request ( method , path , options ) {
@@ -493,11 +493,12 @@ Base.prototype._ = function (args, start, withDoc) {
493
493
494
494
request . f = isFunction ( args [ args . length - 1 ] ) && args . pop ( ) ;
495
495
request . p = isString ( args [ 0 ] ) && encodeURI ( args . shift ( ) ) ;
496
- request . q = args [ withDoc ? 1 : 0 ] || { } ;
497
- request . h = args [ withDoc ? 2 : 1 ] || { } ;
496
+ request . q = args [ withBody ? 1 : 0 ] || { } ;
497
+ request . h = args [ withBody ? 2 : 1 ] || { } ;
498
498
499
- if ( withDoc ) {
500
- if ( doc = ( request . b = args [ 0 ] ) ) {
499
+ if ( withBody ) {
500
+ doc = request . b = args [ 0 ] ;
501
+ if ( ! notDoc ) {
501
502
if ( id = request . p || doc . _id || doc . id ) request . p = id ;
502
503
if ( rev = request . q . rev || doc . _rev || doc . rev ) request . q . rev = rev ;
503
504
}
@@ -1110,8 +1111,8 @@ DB.prototype._changes = function (request) {
1110
1111
*
1111
1112
* @param {String } handler Update handler. Example: mydesign/myhandler
1112
1113
* @param {String } [id] Document ID.
1114
+ * @param {any } data Data.
1113
1115
* @param {Object } [query] HTTP query options.
1114
- * @param {Object|String } [data] Data.
1115
1116
* @param {Object } [headers] Headers.
1116
1117
* @param {handler } [callback] Callback function.
1117
1118
* @return {Promise } A Promise, if no callback is provided,
@@ -1120,7 +1121,7 @@ DB.prototype._changes = function (request) {
1120
1121
*/
1121
1122
1122
1123
DB . prototype . update = function ( handler /* [id], [data], [query], [headers], [callback] */ ) {
1123
- var request = this . _ ( arguments , 1 , 1 ) ;
1124
+ var request = this . _ ( arguments , 1 , 1 , 1 ) ;
1124
1125
var path = handler . split ( "/" , 2 ) ;
1125
1126
1126
1127
path = "_design/" + encodeURIComponent ( path [ 0 ] ) +
0 commit comments