You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is expected and documented behavior. If this behavior is incorrect for your use case, you can disable autoIndex option and use Model.syncIndexes() instead.
syncIndexes() does exactly what you suggest: check MongoDB for which indexes already exist, drop any indexes that are in MongoDB but not in schema, create any indexes that are in schema but not in MongoDB, do nothing with indexes that exist in both schema and MongoDB.
This is expected and documented behavior. If this behavior is incorrect for your use case, you can disable autoIndex option and use Model.syncIndexes() instead.
syncIndexes() does exactly what you suggest: check MongoDB for which indexes already exist, drop any indexes that are in MongoDB but not in schema, create any indexes that are in schema but not in MongoDB, do nothing with indexes that exist in both schema and MongoDB.
syncIndexes does something different, as this syncs Indexes only by each model, not for all models as autoIndex does
Prerequisites
Mongoose version
8.3.4
Node.js version
20.13.1
MongoDB server version
3.6
Typescript version (if applicable)
No response
Description
When connecting with autoIndex option set true (which is the default), mongoose will create the indexes every time the application runs.
Steps to Reproduce
Expected Behavior
Autoindex only create indexes that weren't previously created
The text was updated successfully, but these errors were encountered: