@@ -1276,38 +1276,41 @@ export abstract class BulkOperationBase {
1276
1276
: typeof options === 'function'
1277
1277
? options
1278
1278
: undefined ;
1279
+ options = options != null && typeof options !== 'function' ? options : { } ;
1279
1280
1280
- return maybeCallback ( async ( ) => {
1281
- options = options != null && typeof options !== 'function' ? options : { } ;
1282
-
1283
- if ( this . s . executed ) {
1281
+ if ( this . s . executed ) {
1282
+ // eslint-disable-next-line @typescript-eslint/require-await
1283
+ return maybeCallback ( async ( ) => {
1284
1284
throw new MongoBatchReExecutionError ( ) ;
1285
- }
1285
+ } , callback ) ;
1286
+ }
1286
1287
1287
- const writeConcern = WriteConcern . fromOptions ( options ) ;
1288
- if ( writeConcern ) {
1289
- this . s . writeConcern = writeConcern ;
1290
- }
1288
+ const writeConcern = WriteConcern . fromOptions ( options ) ;
1289
+ if ( writeConcern ) {
1290
+ this . s . writeConcern = writeConcern ;
1291
+ }
1291
1292
1292
- // If we have current batch
1293
- if ( this . isOrdered ) {
1294
- if ( this . s . currentBatch ) this . s . batches . push ( this . s . currentBatch ) ;
1295
- } else {
1296
- if ( this . s . currentInsertBatch ) this . s . batches . push ( this . s . currentInsertBatch ) ;
1297
- if ( this . s . currentUpdateBatch ) this . s . batches . push ( this . s . currentUpdateBatch ) ;
1298
- if ( this . s . currentRemoveBatch ) this . s . batches . push ( this . s . currentRemoveBatch ) ;
1299
- }
1300
- // If we have no operations in the bulk raise an error
1301
- if ( this . s . batches . length === 0 ) {
1293
+ // If we have current batch
1294
+ if ( this . isOrdered ) {
1295
+ if ( this . s . currentBatch ) this . s . batches . push ( this . s . currentBatch ) ;
1296
+ } else {
1297
+ if ( this . s . currentInsertBatch ) this . s . batches . push ( this . s . currentInsertBatch ) ;
1298
+ if ( this . s . currentUpdateBatch ) this . s . batches . push ( this . s . currentUpdateBatch ) ;
1299
+ if ( this . s . currentRemoveBatch ) this . s . batches . push ( this . s . currentRemoveBatch ) ;
1300
+ }
1301
+ // If we have no operations in the bulk raise an error
1302
+ if ( this . s . batches . length === 0 ) {
1303
+ // eslint-disable-next-line @typescript-eslint/require-await
1304
+ return maybeCallback ( async ( ) => {
1302
1305
throw new MongoInvalidArgumentError ( 'Invalid BulkOperation, Batch cannot be empty' ) ;
1303
- }
1306
+ } , callback ) ;
1307
+ }
1304
1308
1305
- this . s . executed = true ;
1306
- const finalOptions = { ...this . s . options , ...options } ;
1307
- const operation = new BulkWriteShimOperation ( this , finalOptions ) ;
1309
+ this . s . executed = true ;
1310
+ const finalOptions = { ...this . s . options , ...options } ;
1311
+ const operation = new BulkWriteShimOperation ( this , finalOptions ) ;
1308
1312
1309
- return await executeOperation ( this . s . collection . s . db . s . client , operation ) ;
1310
- } , callback ) ;
1313
+ return executeOperation ( this . s . collection . s . db . s . client , operation , callback ) ;
1311
1314
}
1312
1315
1313
1316
/**
0 commit comments