@@ -1075,7 +1075,7 @@ module.exports = function(registry) {
10751075 *
10761076 * @param {Number } [since] Since this checkpoint
10771077 * @param {Model } targetModel Target this model class
1078- * @param {Object } [options]
1078+ * @param {Object } [options] An optional options object to pass to underlying data-access calls.
10791079 * @param {Object } [options.filter] Replicate models that match this filter
10801080 * @callback {Function } [callback] Callback function called with `(err, conflicts)` arguments.
10811081 * @param {Error } err Error object; see [Error object](http://docs.strongloop.com/display/LB/Error+object).
@@ -1100,6 +1100,10 @@ module.exports = function(registry) {
11001100 since = { source : since , target : since } ;
11011101 }
11021102
1103+ if ( typeof options === 'function' ) {
1104+ options = { } ;
1105+ }
1106+
11031107 options = options || { } ;
11041108
11051109 var sourceModel = this ;
@@ -1214,7 +1218,7 @@ module.exports = function(registry) {
12141218 function bulkUpdate ( _updates , cb ) {
12151219 debug ( '\tstarting bulk update' ) ;
12161220 updates = _updates ;
1217- targetModel . bulkUpdate ( updates , function ( err ) {
1221+ targetModel . bulkUpdate ( updates , options , function ( err ) {
12181222 var conflicts = err && err . details && err . details . conflicts ;
12191223 if ( conflicts && err . statusCode == 409 ) {
12201224 diff . conflicts = conflicts ;
@@ -1328,15 +1332,28 @@ module.exports = function(registry) {
13281332 * **Note: this is not atomic**
13291333 *
13301334 * @param {Array } updates An updates list, usually from [createUpdates()](#persistedmodel-createupdates).
1335+ * @param {Object } [options] An optional options object to pass to underlying data-access calls.
13311336 * @param {Function } callback Callback function.
13321337 */
13331338
1334- PersistedModel . bulkUpdate = function ( updates , callback ) {
1339+ PersistedModel . bulkUpdate = function ( updates , options , callback ) {
13351340 var tasks = [ ] ;
13361341 var Model = this ;
13371342 var Change = this . getChangeModel ( ) ;
13381343 var conflicts = [ ] ;
13391344
1345+ var lastArg = arguments [ arguments . length - 1 ] ;
1346+
1347+ if ( typeof lastArg === 'function' && arguments . length > 1 ) {
1348+ callback = lastArg ;
1349+ }
1350+
1351+ if ( typeof options === 'function' ) {
1352+ options = { } ;
1353+ }
1354+
1355+ options = options || { } ;
1356+
13401357 buildLookupOfAffectedModelData ( Model , updates , function ( err , currentMap ) {
13411358 if ( err ) return callback ( err ) ;
13421359
@@ -1346,18 +1363,18 @@ module.exports = function(registry) {
13461363 switch ( update . type ) {
13471364 case Change . UPDATE :
13481365 tasks . push ( function ( cb ) {
1349- applyUpdate ( Model , id , current , update . data , update . change , conflicts , cb ) ;
1366+ applyUpdate ( Model , id , current , update . data , update . change , conflicts , options , cb ) ;
13501367 } ) ;
13511368 break ;
13521369
13531370 case Change . CREATE :
13541371 tasks . push ( function ( cb ) {
1355- applyCreate ( Model , id , current , update . data , update . change , conflicts , cb ) ;
1372+ applyCreate ( Model , id , current , update . data , update . change , conflicts , options , cb ) ;
13561373 } ) ;
13571374 break ;
13581375 case Change . DELETE :
13591376 tasks . push ( function ( cb ) {
1360- applyDelete ( Model , id , current , update . change , conflicts , cb ) ;
1377+ applyDelete ( Model , id , current , update . change , conflicts , options , cb ) ;
13611378 } ) ;
13621379 break ;
13631380 }
@@ -1391,7 +1408,7 @@ module.exports = function(registry) {
13911408 } ) ;
13921409 }
13931410
1394- function applyUpdate ( Model , id , current , data , change , conflicts , cb ) {
1411+ function applyUpdate ( Model , id , current , data , change , conflicts , options , cb ) {
13951412 var Change = Model . getChangeModel ( ) ;
13961413 var rev = current ? Change . revisionForInst ( current ) : null ;
13971414
@@ -1409,7 +1426,7 @@ module.exports = function(registry) {
14091426 // but not included in `data`
14101427 // See https://github.com/strongloop/loopback/issues/1215
14111428
1412- Model . updateAll ( current . toObject ( ) , data , function ( err , result ) {
1429+ Model . updateAll ( current . toObject ( ) , data , options , function ( err , result ) {
14131430 if ( err ) return cb ( err ) ;
14141431
14151432 var count = result && result . count ;
@@ -1444,8 +1461,8 @@ module.exports = function(registry) {
14441461 } ) ;
14451462 }
14461463
1447- function applyCreate ( Model , id , current , data , change , conflicts , cb ) {
1448- Model . create ( data , function ( createErr ) {
1464+ function applyCreate ( Model , id , current , data , change , conflicts , options , cb ) {
1465+ Model . create ( data , options , function ( createErr ) {
14491466 if ( ! createErr ) return cb ( ) ;
14501467
14511468 // We don't have a reliable way how to detect the situation
@@ -1473,7 +1490,7 @@ module.exports = function(registry) {
14731490 }
14741491 }
14751492
1476- function applyDelete ( Model , id , current , change , conflicts , cb ) {
1493+ function applyDelete ( Model , id , current , change , conflicts , options , cb ) {
14771494 if ( ! current ) {
14781495 // The instance was either already deleted or not created at all,
14791496 // we are done.
@@ -1491,7 +1508,7 @@ module.exports = function(registry) {
14911508 return Change . rectifyModelChanges ( Model . modelName , [ id ] , cb ) ;
14921509 }
14931510
1494- Model . deleteAll ( current . toObject ( ) , function ( err , result ) {
1511+ Model . deleteAll ( current . toObject ( ) , options , function ( err , result ) {
14951512 if ( err ) return cb ( err ) ;
14961513
14971514 var count = result && result . count ;
0 commit comments