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

feat(model): add hideIndexes option to syncIndexes() and cleanIndexes() #14987

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14868

Summary

Add an option to make syncIndexes() mark indexes as hidden (see MongoDB hidden indexes docs) as opposed to dropping them. Hidden indexes are useful because rebuilding an index can be expensive, so if you accidentally drop a index that you shouldn't it can take a while to recover. With hidden indexes, you can test whether removing this index will cause performance issues without actually dropping the index. syncIndexes({ hideIndex: true }) will hide all non-schema indexes rather than dropping them.

Hidden index support was added in MongoDB 4.4 so we should make a quick note about version compatibility, since Mongoose 8 technically supports all the way back to MongoDB 3.6.

Examples

@vkarpov15 vkarpov15 added this to the 8.8 milestone Oct 28, 2024
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit a60e72d into 8.8 Oct 28, 2024
61 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14868 branch October 28, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants