Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(schema): add missing search index types #14449

Merged
merged 2 commits into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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