@@ -1289,4 +1289,31 @@ describe('Indexes', function () {
1289
1289
)
1290
1290
) ;
1291
1291
} ) ;
1292
+
1293
+ it ( 'should create index hidden' , {
1294
+ metadata : { requires : { mongodb : '>=4.4' , topology : 'single' } } ,
1295
+ test : function ( done ) {
1296
+ const configuration = this . configuration ;
1297
+ const client = configuration . newClient ( configuration . writeConcernMax ( ) , { poolSize : 1 } ) ;
1298
+ client . connect ( function ( err , client ) {
1299
+ expect ( err ) . to . not . exist ;
1300
+ const db = client . db ( configuration . db ) ;
1301
+ db . createCollection ( 'hidden_index_collection' , ( err , collection ) => {
1302
+ expect ( err ) . to . not . exist ;
1303
+ collection . createIndex ( 'a' , { hidden : true } , ( err , index ) => {
1304
+ expect ( err ) . to . not . exist ;
1305
+ expect ( index ) . to . equal ( 'a_1' ) ;
1306
+ collection . listIndexes ( ) . toArray ( ( err , indexes ) => {
1307
+ expect ( err ) . to . not . exist ;
1308
+ expect ( indexes ) . to . deep . equal ( [
1309
+ { v : 2 , key : { _id : 1 } , name : '_id_' } ,
1310
+ { v : 2 , key : { a : 1 } , name : 'a_1' , hidden : true }
1311
+ ] ) ;
1312
+ client . close ( done ) ;
1313
+ } ) ;
1314
+ } ) ;
1315
+ } ) ;
1316
+ } ) ;
1317
+ }
1318
+ } ) ;
1292
1319
} ) ;
0 commit comments