@@ -295,15 +295,30 @@ operations.set('dropCollection', async ({ entities, operation }) => {
295
295
}
296
296
} ) ;
297
297
298
+ operations . set ( 'drop' , async ( { entities, operation } ) => {
299
+ const bucket = entities . getEntity ( 'bucket' , operation . object ) ;
300
+ return bucket . drop ( ) ;
301
+ } ) ;
302
+
303
+ operations . set ( 'dropIndexes' , async ( { entities, operation } ) => {
304
+ const collection = entities . getEntity ( 'collection' , operation . object ) ;
305
+ return collection . dropIndexes ( ) ;
306
+ } ) ;
307
+
298
308
operations . set ( 'endSession' , async ( { entities, operation } ) => {
299
309
const session = entities . getEntity ( 'session' , operation . object ) ;
300
310
return session . endSession ( ) ;
301
311
} ) ;
302
312
303
313
operations . set ( 'find' , async ( { entities, operation } ) => {
304
- const collection = entities . getEntity ( 'collection' , operation . object ) ;
314
+ let queryable ;
315
+ if ( operation . object === 'bucket' ) {
316
+ queryable = entities . getEntity ( 'bucket' , operation . object ) ;
317
+ } else {
318
+ queryable = entities . getEntity ( 'collection' , operation . object ) ;
319
+ }
305
320
const { filter, ...opts } = operation . arguments ! ;
306
- return collection . find ( filter , opts ) . toArray ( ) ;
321
+ return queryable . find ( filter , opts ) . toArray ( ) ;
307
322
} ) ;
308
323
309
324
operations . set ( 'findOne' , async ( { entities, operation } ) => {
@@ -372,16 +387,35 @@ operations.set('listCollections', async ({ entities, operation }) => {
372
387
return db . listCollections ( filter , opts ) . toArray ( ) ;
373
388
} ) ;
374
389
390
+ operations . set ( 'listCollectionNames' , async ( { entities, operation } ) => {
391
+ const db = entities . getEntity ( 'db' , operation . object ) ;
392
+ const { filter, ...opts } = operation . arguments ! ;
393
+ const collections = await db . listCollections ( filter , opts ) . toArray ( ) ;
394
+ return collections . map ( collection => collection . name ) ;
395
+ } ) ;
396
+
375
397
operations . set ( 'listDatabases' , async ( { entities, operation } ) => {
376
398
const client = entities . getEntity ( 'client' , operation . object ) ;
377
399
return client . db ( ) . admin ( ) . listDatabases ( operation . arguments ! ) ;
378
400
} ) ;
379
401
402
+ operations . set ( 'listDatabaseNames' , async ( { entities, operation } ) => {
403
+ const client = entities . getEntity ( 'client' , operation . object ) ;
404
+ const result = await client . db ( ) . admin ( ) . listDatabases ( operation . arguments ! ) ;
405
+ return result . databases . map ( database => database . name ) ;
406
+ } ) ;
407
+
380
408
operations . set ( 'listIndexes' , async ( { entities, operation } ) => {
381
409
const collection = entities . getEntity ( 'collection' , operation . object ) ;
382
410
return collection . listIndexes ( operation . arguments ! ) . toArray ( ) ;
383
411
} ) ;
384
412
413
+ operations . set ( 'listIndexNames' , async ( { entities, operation } ) => {
414
+ const collection = entities . getEntity ( 'collection' , operation . object ) ;
415
+ const indexes = await collection . listIndexes ( operation . arguments ! ) . toArray ( ) ;
416
+ return indexes . map ( index => index . name ) ;
417
+ } ) ;
418
+
385
419
operations . set ( 'loop' , async ( { entities, operation, client, testConfig } ) => {
386
420
const controller = new AbortController ( ) ;
387
421
// We always want the process to exit on SIGINT last, so all other
@@ -680,6 +714,12 @@ operations.set('withTransaction', async ({ entities, operation, client, testConf
680
714
} , options ) ;
681
715
} ) ;
682
716
717
+ operations . set ( 'count' , async ( { entities, operation } ) => {
718
+ const collection = entities . getEntity ( 'collection' , operation . object ) ;
719
+ const { filter, ...opts } = operation . arguments ! ;
720
+ return collection . count ( filter , opts ) ;
721
+ } ) ;
722
+
683
723
operations . set ( 'countDocuments' , async ( { entities, operation } ) => {
684
724
const collection = entities . getEntity ( 'collection' , operation . object ) ;
685
725
const { filter, ...opts } = operation . arguments ! ;
0 commit comments