Skip to content

Commit

Permalink
feat: adds "hidden" option when creating indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Reggi authored Sep 25, 2020
1 parent e2f021d commit ee8ca1a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/operations/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const VALID_INDEX_OPTIONS = new Set([
'name',
'partialFilterExpression',
'sparse',
'hidden',
'expireAfterSeconds',
'storageEngine',
'collation',
Expand Down
27 changes: 27 additions & 0 deletions test/functional/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,4 +1289,31 @@ describe('Indexes', function () {
)
);
});

it('should create index hidden', {
metadata: { requires: { mongodb: '>=4.4', topology: 'single' } },
test: function (done) {
const configuration = this.configuration;
const client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 });
client.connect(function (err, client) {
expect(err).to.not.exist;
const db = client.db(configuration.db);
db.createCollection('hidden_index_collection', (err, collection) => {
expect(err).to.not.exist;
collection.createIndex('a', { hidden: true }, (err, index) => {
expect(err).to.not.exist;
expect(index).to.equal('a_1');
collection.listIndexes().toArray((err, indexes) => {
expect(err).to.not.exist;
expect(indexes).to.deep.equal([
{ v: 2, key: { _id: 1 }, name: '_id_' },
{ v: 2, key: { a: 1 }, name: 'a_1', hidden: true }
]);
client.close(done);
});
});
});
});
}
});
});

0 comments on commit ee8ca1a

Please sign in to comment.