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