@@ -144,6 +144,7 @@ DynamoTable.prototype.update = function(key, actions, options, cb) {
144
144
// If actions is a string or array, then it's a whitelist for attributes to update
145
145
if ( typeof actions === 'string' ) actions = [ actions ]
146
146
if ( Array . isArray ( actions ) ) { pick = actions ; actions = key ; key = null }
147
+ if ( ! actions ) { actions = key ; key = null }
147
148
148
149
// If key is null, assume actions has a full object to put so clone it (without keys)
149
150
if ( key == null ) {
@@ -315,7 +316,16 @@ DynamoTable.prototype.batchGet = function(keys, options, tables, cb) {
315
316
316
317
// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
317
318
DynamoTable . MAX_WRITE = 25
318
- DynamoTable . prototype . batchWrite = function ( operations , tables , cb ) {
319
+ DynamoTable . prototype . batchWrite = function ( operations , tables , options , cb ) {
320
+ if ( ! cb ) {
321
+ cb = options ;
322
+ if ( Object . prototype . toString . call ( tables ) === '[object Object]' ) {
323
+ options = tables ;
324
+ tables = [ ] ;
325
+ } else {
326
+ options = { }
327
+ }
328
+ }
319
329
if ( ! cb ) { cb = tables ; tables = [ ] }
320
330
if ( typeof cb !== 'function' ) throw new Error ( 'Last parameter must be a callback function' )
321
331
cb = once ( cb )
@@ -353,7 +363,8 @@ DynamoTable.prototype.batchWrite = function(operations, tables, cb) {
353
363
}
354
364
355
365
function batchRequest ( requestItems , cb ) {
356
- self . client . request ( 'BatchWriteItem' , { RequestItems : requestItems } , function ( err , data ) {
366
+ options . RequestItems = requestItems
367
+ self . client . request ( 'BatchWriteItem' , options , function ( err , data ) {
357
368
if ( err ) return cb ( err )
358
369
if ( Object . keys ( data . UnprocessedItems || { } ) . length )
359
370
return batchRequest ( data . UnprocessedItems , cb )
0 commit comments