@@ -1276,41 +1276,37 @@ export abstract class BulkOperationBase {
1276
1276
: typeof options === 'function'
1277
1277
? options
1278
1278
: undefined ;
1279
- options = options != null && typeof options !== 'function' ? options : { } ;
1279
+ return maybeCallback ( async ( ) => {
1280
+ options = options != null && typeof options !== 'function' ? options : { } ;
1280
1281
1281
- if ( this . s . executed ) {
1282
- // eslint-disable-next-line @typescript-eslint/require-await
1283
- return maybeCallback ( async ( ) => {
1282
+ if ( this . s . executed ) {
1284
1283
throw new MongoBatchReExecutionError ( ) ;
1285
- } , callback ) ;
1286
- }
1284
+ }
1287
1285
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
+ }
1292
1290
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 ) {
1305
1301
throw new MongoInvalidArgumentError ( 'Invalid BulkOperation, Batch cannot be empty' ) ;
1306
- } , callback ) ;
1307
- }
1302
+ }
1308
1303
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 ) ;
1312
1307
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 ) ;
1314
1310
}
1315
1311
1316
1312
/**
0 commit comments