Enhance Mongoose Typings with SearchMeta Interface for Atlas Search #13792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add search meta
Summary:
This pull request extends the Mongoose module typings by incorporating the SearchMeta interface. This addition offers better type definitions for developers leveraging MongoDB Atlas Search, ensuring that their implementations are more type-safe and adhere to the expected structure.
Motivation:
With MongoDB Atlas Search gaining traction, many developers are harnessing its full-text search capabilities within their Mongoose-based applications. By providing detailed type definitions, we can simplify their development process, prevent type-related errors, and encourage best practices.
Key Features:
Introduced the SearchMeta interface that encapsulates the $searchMeta aggregation pipeline stage.
Included annotations for the possible properties within this stage, such as index, highlight, and their respective sub-properties.
Provided direct links to official MongoDB documentation for easy reference.
Examples:
For a developer implementing the Atlas Search with Mongoose, they can now expect type suggestions and checks for the $searchMeta stage:
With these typings in place, incorrect implementations, such as an invalid property in $searchMeta, will be flagged by TypeScript, offering a more reliable development experience.
Note: For contributors, while updating documentation, please refer to the corresponding .pug files rather than directly editing .html files.