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
Noisy irrelevant warning: "mongoose: Cannot specify a custom index on _id
for model name "Settings", MongoDB does not allow overwriting the default _id
index. See http://bit.ly/mongodb-id-index"
#8462
Comments
That's because every MongoDB collection has a special index on
Why are you setting |
I suppose that it's my old experience from the SQL world. To explicitly set unique for Yep, I have just tried
and obtain 2 records with For my test case above I just removed the unique index on So my problem completely resolved when I removed Anyway, MongoDB allows us to pass You may close this issue if think that this warning is helpful for developers. |
The problem is that setting |
This should be reopened.
It says it must be unique, it doesn't say it's always unique regardless of what you want, so I would naturally try to make it unique by adding |
@simoncarbajal MongoDB's docs say that the value of |
Do you want to request a feature or report a bug?
BUG
What is the current behavior?
If we use the type
String
for_id
field and make themunique
index then we got the following noise warning:But MongoDB correctly works with such type for
_id
field. And by the provided link http://bit.ly/mongodb-id-index I did not find any restriction for_id
field type. Moreover mongoose also correctly works but does not allow to hide this noisy warning.If the current behavior is a bug, please provide the steps to reproduce.
The following JEST test works well and the correct data stored in MongoDB's collection. And if we try to save another record with the existed value we got EXPECTED (E11000) error that record already exists.
What is the expected behavior?
Allow hiding warning message or remove it at all.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
5.7.12 and checked with upstream code:
mongoose/lib/model.js
Lines 1587 to 1595 in 7fae539
Related old issues: #6650 #7053
The text was updated successfully, but these errors were encountered: