Skip to content

Commit

Permalink
Merge pull request #14449 from noseworthy/add-search-index-types
Browse files Browse the repository at this point in the history
types(schema): add missing search index types
  • Loading branch information
vkarpov15 committed Mar 20, 2024
2 parents c3c405e + aea12a1 commit d516f50
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions types/index.d.ts
Expand Up @@ -274,6 +274,13 @@ declare module 'mongoose' {
/** Defines an index (most likely compound) for this schema. */
index(fields: IndexDefinition, options?: IndexOptions): this;

/**
* Define a search index for this schema.
*
* @remarks Search indexes are only supported when used against a 7.0+ Mongo Atlas cluster.
*/
searchIndex(description: mongodb.SearchIndexDescription): this;

/**
* Returns a list of indexes that this schema declares, via `schema.index()`
* or by `index: true` in a path's options.
Expand Down
5 changes: 5 additions & 0 deletions types/schemaoptions.d.ts
Expand Up @@ -24,6 +24,11 @@ declare module 'mongoose' {
* automatic index builds, you can set autoIndex to false.
*/
autoIndex?: boolean;
/**
* Similar to autoIndex, except for automatically creates any Atlas search indexes defined in your
* schema. Unlike autoIndex, this option defaults to false.
*/
autoSearchIndex?: boolean;
/**
* If set to `true`, Mongoose will call Model.createCollection() to create the underlying collection
* in MongoDB if autoCreate is set to true. Calling createCollection() sets the collection's default
Expand Down

0 comments on commit d516f50

Please sign in to comment.