-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
index setting error occurred at 8.9.1("Schema already has an index") #15109
Comments
We had the same error for a slightly different scenario: we had declared the
removing the |
I have the same issue with this use case:
|
Error seems to be in new code for 8.9.1 (lib/schema.js): isDeepStrictEqual-function returns true for index definitionswhich have same fields in different order. Normally in javascript objects the order of properties should not matter. For mongoose/mongodb the order if items is meaningful: |
fix(schema): avoid throwing duplicate index error if index spec keys have different order or index has a custom name
When can we expect a new release with a fix? This broke all our DB connections and difficult to port back to older mongoose release. Can this have a priority? |
ran into the same issue & this seems to have fixed it 🤝 |
I have another regression with nestjs. See nestjs/mongoose#2346. |
Yes, this also solved it for us. However, there is no information in the mongoose SchemaType section explaining "unique"=true creates an index too. Therefore, it would be highly appreciated to get clarification at least in the documentation, ideally with a warning info. |
We will change this error into a warning instead to prevent it from blocking anyone from upgrading. |
This has solved it for us too, thank you 💯 |
fix(schema): make duplicate index error a warning for now to prevent blocking upgrading
Prerequisites
Issue
Error message
Schema
mongoDB
In my opinion, the two indexes seem to work differently in MongoDB.
why is this causing an error in mongoose? It works correctly in [email protected], but it behaves abnormally in [email protected].
The text was updated successfully, but these errors were encountered: