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