@@ -42,7 +42,7 @@ operations.set('aggregate', async ({ entities, operation }) => {
42
42
if ( ! ( dbOrCollection instanceof Db || dbOrCollection instanceof Collection ) ) {
43
43
throw new Error ( `Operation object '${ operation . object } ' must be a db or collection` ) ;
44
44
}
45
- const { pipeline, ...opts } = operation . arguments ?? { } ;
45
+ const { pipeline, ...opts } = operation . arguments ! ;
46
46
const cursor = dbOrCollection . aggregate ( pipeline , opts ) ;
47
47
return cursor . toArray ( ) ;
48
48
} ) ;
@@ -181,7 +181,7 @@ operations.set('assertNumberConnectionsCheckedOut', async ({ entities, operation
181
181
182
182
operations . set ( 'bulkWrite' , async ( { entities, operation } ) => {
183
183
const collection = entities . getEntity ( 'collection' , operation . object ) ;
184
- const { requests, ...opts } = operation . arguments ?? { } ;
184
+ const { requests, ...opts } = operation . arguments ! ;
185
185
return collection . bulkWrite ( requests , opts ) ;
186
186
} ) ;
187
187
@@ -209,7 +209,7 @@ operations.set('createChangeStream', async ({ entities, operation }) => {
209
209
throw new Error ( `Entity ${ operation . object } must be watchable` ) ;
210
210
}
211
211
212
- const { pipeline, ...args } = operation . arguments ?? { } ;
212
+ const { pipeline, ...args } = operation . arguments ! ;
213
213
const changeStream = watchable . watch ( pipeline , args ) ;
214
214
215
215
return new Promise ( ( resolve , reject ) => {
@@ -223,13 +223,13 @@ operations.set('createChangeStream', async ({ entities, operation }) => {
223
223
224
224
operations . set ( 'createCollection' , async ( { entities, operation } ) => {
225
225
const db = entities . getEntity ( 'db' , operation . object ) ;
226
- const { collection, ...opts } = operation . arguments ?? { } ;
226
+ const { collection, ...opts } = operation . arguments ! ;
227
227
return await db . createCollection ( collection , opts ) ;
228
228
} ) ;
229
229
230
230
operations . set ( 'createFindCursor' , async ( { entities, operation } ) => {
231
231
const collection = entities . getEntity ( 'collection' , operation . object ) ;
232
- const { filter, ...opts } = operation . arguments ?? { } ;
232
+ const { filter, ...opts } = operation . arguments ! ;
233
233
const cursor = collection . find ( filter , opts ) ;
234
234
// The spec dictates that we create the cursor and force the find command
235
235
// to execute, but don't move the cursor forward. hasNext() accomplishes
@@ -240,25 +240,25 @@ operations.set('createFindCursor', async ({ entities, operation }) => {
240
240
241
241
operations . set ( 'createIndex' , async ( { entities, operation } ) => {
242
242
const collection = entities . getEntity ( 'collection' , operation . object ) ;
243
- const { keys, ...opts } = operation . arguments ?? { } ;
243
+ const { keys, ...opts } = operation . arguments ! ;
244
244
await collection . createIndex ( keys , opts ) ;
245
245
} ) ;
246
246
247
247
operations . set ( 'dropIndex' , async ( { entities, operation } ) => {
248
248
const collection = entities . getEntity ( 'collection' , operation . object ) ;
249
- const { name, ...opts } = operation . arguments ?? { } ;
249
+ const { name, ...opts } = operation . arguments ! ;
250
250
await collection . dropIndex ( name , opts ) ;
251
251
} ) ;
252
252
253
253
operations . set ( 'deleteOne' , async ( { entities, operation } ) => {
254
254
const collection = entities . getEntity ( 'collection' , operation . object ) ;
255
- const { filter, ...options } = operation . arguments ?? { } ;
255
+ const { filter, ...options } = operation . arguments ! ;
256
256
return collection . deleteOne ( filter , options ) ;
257
257
} ) ;
258
258
259
259
operations . set ( 'dropCollection' , async ( { entities, operation } ) => {
260
260
const db = entities . getEntity ( 'db' , operation . object ) ;
261
- const { collection, ...opts } = operation . arguments ?? { } ;
261
+ const { collection, ...opts } = operation . arguments ! ;
262
262
263
263
// TODO(NODE-4243): dropCollection should suppress namespace not found errors
264
264
try {
@@ -277,25 +277,25 @@ operations.set('endSession', async ({ entities, operation }) => {
277
277
278
278
operations . set ( 'find' , async ( { entities, operation } ) => {
279
279
const collection = entities . getEntity ( 'collection' , operation . object ) ;
280
- const { filter, ...opts } = operation . arguments ?? { } ;
280
+ const { filter, ...opts } = operation . arguments ! ;
281
281
return collection . find ( filter , opts ) . toArray ( ) ;
282
282
} ) ;
283
283
284
284
operations . set ( 'findOneAndReplace' , async ( { entities, operation } ) => {
285
285
const collection = entities . getEntity ( 'collection' , operation . object ) ;
286
- const { filter, replacement, ...opts } = operation . arguments ?? { } ;
286
+ const { filter, replacement, ...opts } = operation . arguments ! ;
287
287
return ( await collection . findOneAndReplace ( filter , replacement , translateOptions ( opts ) ) ) . value ;
288
288
} ) ;
289
289
290
290
operations . set ( 'findOneAndUpdate' , async ( { entities, operation } ) => {
291
291
const collection = entities . getEntity ( 'collection' , operation . object ) ;
292
- const { filter, update, ...opts } = operation . arguments ?? { } ;
292
+ const { filter, update, ...opts } = operation . arguments ! ;
293
293
return ( await collection . findOneAndUpdate ( filter , update , translateOptions ( opts ) ) ) . value ;
294
294
} ) ;
295
295
296
296
operations . set ( 'findOneAndDelete' , async ( { entities, operation } ) => {
297
297
const collection = entities . getEntity ( 'collection' , operation . object ) ;
298
- const { filter, ...opts } = operation . arguments ?? { } ;
298
+ const { filter, ...opts } = operation . arguments ! ;
299
299
return ( await collection . findOneAndDelete ( filter , opts ) ) . value ;
300
300
} ) ;
301
301
@@ -306,13 +306,13 @@ operations.set('failPoint', async ({ entities, operation }) => {
306
306
307
307
operations . set ( 'insertOne' , async ( { entities, operation } ) => {
308
308
const collection = entities . getEntity ( 'collection' , operation . object ) ;
309
- const { document, ...opts } = operation . arguments ?? { } ;
309
+ const { document, ...opts } = operation . arguments ! ;
310
310
return collection . insertOne ( document , opts ) ;
311
311
} ) ;
312
312
313
313
operations . set ( 'insertMany' , async ( { entities, operation } ) => {
314
314
const collection = entities . getEntity ( 'collection' , operation . object ) ;
315
- const { documents, ...opts } = operation . arguments ?? { } ;
315
+ const { documents, ...opts } = operation . arguments ! ;
316
316
return collection . insertMany ( documents , opts ) ;
317
317
} ) ;
318
318
@@ -341,26 +341,23 @@ operations.set('iterateUntilDocumentOrError', async ({ entities, operation }) =>
341
341
342
342
operations . set ( 'listCollections' , async ( { entities, operation } ) => {
343
343
const db = entities . getEntity ( 'db' , operation . object ) ;
344
- const { filter, ...opts } = operation . arguments ?? { } ;
344
+ const { filter, ...opts } = operation . arguments ! ;
345
345
return db . listCollections ( filter , opts ) . toArray ( ) ;
346
346
} ) ;
347
347
348
348
operations . set ( 'listDatabases' , async ( { entities, operation } ) => {
349
349
const client = entities . getEntity ( 'client' , operation . object ) ;
350
- return client
351
- . db ( )
352
- . admin ( )
353
- . listDatabases ( operation . arguments ?? { } ) ;
350
+ return client . db ( ) . admin ( ) . listDatabases ( operation . arguments ! ) ;
354
351
} ) ;
355
352
356
353
operations . set ( 'listIndexes' , async ( { entities, operation } ) => {
357
354
const collection = entities . getEntity ( 'collection' , operation . object ) ;
358
- return collection . listIndexes ( operation . arguments ?? { } ) . toArray ( ) ;
355
+ return collection . listIndexes ( operation . arguments ! ) . toArray ( ) ;
359
356
} ) ;
360
357
361
358
operations . set ( 'replaceOne' , async ( { entities, operation } ) => {
362
359
const collection = entities . getEntity ( 'collection' , operation . object ) ;
363
- const { filter, replacement, ...opts } = operation . arguments ?? { } ;
360
+ const { filter, replacement, ...opts } = operation . arguments ! ;
364
361
return collection . replaceOne ( filter , replacement , opts ) ;
365
362
} ) ;
366
363
@@ -430,61 +427,61 @@ operations.set('withTransaction', async ({ entities, operation, client }) => {
430
427
431
428
operations . set ( 'countDocuments' , async ( { entities, operation } ) => {
432
429
const collection = entities . getEntity ( 'collection' , operation . object ) ;
433
- const { filter, ...opts } = operation . arguments ?? { } ;
430
+ const { filter, ...opts } = operation . arguments ! ;
434
431
return collection . countDocuments ( filter , opts ) ;
435
432
} ) ;
436
433
437
434
operations . set ( 'deleteMany' , async ( { entities, operation } ) => {
438
435
const collection = entities . getEntity ( 'collection' , operation . object ) ;
439
- const { filter, ...opts } = operation . arguments ?? { } ;
436
+ const { filter, ...opts } = operation . arguments ! ;
440
437
return collection . deleteMany ( filter , opts ) ;
441
438
} ) ;
442
439
443
440
operations . set ( 'distinct' , async ( { entities, operation } ) => {
444
441
const collection = entities . getEntity ( 'collection' , operation . object ) ;
445
- const { fieldName, filter, ...opts } = operation . arguments ?? { } ;
442
+ const { fieldName, filter, ...opts } = operation . arguments ! ;
446
443
return collection . distinct ( fieldName , filter , opts ) ;
447
444
} ) ;
448
445
449
446
operations . set ( 'estimatedDocumentCount' , async ( { entities, operation } ) => {
450
447
const collection = entities . getEntity ( 'collection' , operation . object ) ;
451
- return collection . estimatedDocumentCount ( operation . arguments ?? { } ) ;
448
+ return collection . estimatedDocumentCount ( operation . arguments ! ) ;
452
449
} ) ;
453
450
454
451
operations . set ( 'runCommand' , async ( { entities, operation } : OperationFunctionParams ) => {
455
452
const db = entities . getEntity ( 'db' , operation . object ) ;
456
- const { command, ...opts } = operation . arguments ?? { } ;
453
+ const { command, ...opts } = operation . arguments ! ;
457
454
return db . command ( command , opts ) ;
458
455
} ) ;
459
456
460
457
operations . set ( 'updateMany' , async ( { entities, operation } ) => {
461
458
const collection = entities . getEntity ( 'collection' , operation . object ) ;
462
- const { filter, update, ...options } = operation . arguments ?? { } ;
459
+ const { filter, update, ...options } = operation . arguments ! ;
463
460
return collection . updateMany ( filter , update , options ) ;
464
461
} ) ;
465
462
466
463
operations . set ( 'updateOne' , async ( { entities, operation } ) => {
467
464
const collection = entities . getEntity ( 'collection' , operation . object ) ;
468
- const { filter, update, ...options } = operation . arguments ?? { } ;
465
+ const { filter, update, ...options } = operation . arguments ! ;
469
466
return collection . updateOne ( filter , update , options ) ;
470
467
} ) ;
471
468
472
469
operations . set ( 'rename' , async ( { entities, operation } ) => {
473
470
const collection = entities . getEntity ( 'collection' , operation . object ) ;
474
- const { to, ...options } = operation . arguments ?? { } ;
471
+ const { to, ...options } = operation . arguments ! ;
475
472
return collection . rename ( to , options ) ;
476
473
} ) ;
477
474
478
475
operations . set ( 'createDataKey' , async ( { entities, operation } ) => {
479
476
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
480
- const { kmsProvider, opts } = operation . arguments ?? { } ;
477
+ const { kmsProvider, opts } = operation . arguments ! ;
481
478
482
479
return clientEncryption . createDataKey ( kmsProvider , opts ) ;
483
480
} ) ;
484
481
485
482
operations . set ( 'rewrapManyDataKey' , async ( { entities, operation } ) => {
486
483
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
487
- const { filter, opts } = operation . arguments ?? { } ;
484
+ const { filter, opts } = operation . arguments ! ;
488
485
489
486
const rewrapManyDataKeyResult = await clientEncryption . rewrapManyDataKey ( filter , opts ) ;
490
487
@@ -506,14 +503,14 @@ operations.set('rewrapManyDataKey', async ({ entities, operation }) => {
506
503
507
504
operations . set ( 'deleteKey' , async ( { entities, operation } ) => {
508
505
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
509
- const { id } = operation . arguments ?? { } ;
506
+ const { id } = operation . arguments ! ;
510
507
511
508
return clientEncryption . deleteKey ( id ) ;
512
509
} ) ;
513
510
514
511
operations . set ( 'getKey' , async ( { entities, operation } ) => {
515
512
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
516
- const { id } = operation . arguments ?? { } ;
513
+ const { id } = operation . arguments ! ;
517
514
518
515
return clientEncryption . getKey ( id ) ;
519
516
} ) ;
@@ -526,21 +523,21 @@ operations.set('getKeys', async ({ entities, operation }) => {
526
523
527
524
operations . set ( 'addKeyAltName' , async ( { entities, operation } ) => {
528
525
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
529
- const { id, keyAltName } = operation . arguments ?? { } ;
526
+ const { id, keyAltName } = operation . arguments ! ;
530
527
531
528
return clientEncryption . addKeyAltName ( id , keyAltName ) ;
532
529
} ) ;
533
530
534
531
operations . set ( 'removeKeyAltName' , async ( { entities, operation } ) => {
535
532
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
536
- const { id, keyAltName } = operation . arguments ?? { } ;
533
+ const { id, keyAltName } = operation . arguments ! ;
537
534
538
535
return clientEncryption . removeKeyAltName ( id , keyAltName ) ;
539
536
} ) ;
540
537
541
538
operations . set ( 'getKeyByAltName' , async ( { entities, operation } ) => {
542
539
const clientEncryption = entities . getEntity ( 'clientEncryption' , operation . object ) ;
543
- const { keyAltName } = operation . arguments ?? { } ;
540
+ const { keyAltName } = operation . arguments ! ;
544
541
545
542
return clientEncryption . getKeyByAltName ( keyAltName ) ;
546
543
} ) ;
0 commit comments