Skip to content

Commit d516f50

Browse files
authored
Merge pull request #14449 from noseworthy/add-search-index-types
types(schema): add missing search index types
2 parents c3c405e + aea12a1 commit d516f50

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

types/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ declare module 'mongoose' {
274274
/** Defines an index (most likely compound) for this schema. */
275275
index(fields: IndexDefinition, options?: IndexOptions): this;
276276

277+
/**
278+
* Define a search index for this schema.
279+
*
280+
* @remarks Search indexes are only supported when used against a 7.0+ Mongo Atlas cluster.
281+
*/
282+
searchIndex(description: mongodb.SearchIndexDescription): this;
283+
277284
/**
278285
* Returns a list of indexes that this schema declares, via `schema.index()`
279286
* or by `index: true` in a path's options.

types/schemaoptions.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ declare module 'mongoose' {
2424
* automatic index builds, you can set autoIndex to false.
2525
*/
2626
autoIndex?: boolean;
27+
/**
28+
* Similar to autoIndex, except for automatically creates any Atlas search indexes defined in your
29+
* schema. Unlike autoIndex, this option defaults to false.
30+
*/
31+
autoSearchIndex?: boolean;
2732
/**
2833
* If set to `true`, Mongoose will call Model.createCollection() to create the underlying collection
2934
* in MongoDB if autoCreate is set to true. Calling createCollection() sets the collection's default

0 commit comments

Comments
 (0)