Hi, I’m currently working on the exercise tracker project. I’m using mongo v3.6.3
Then I’m getting a weird warning on my console which is mongoose: Cannot specify a custom index on
_idfor model name "Users", MongoDB does not allow overwriting the default
_idindex. See http://bit.ly/mongodb-id-index
. It only shows when I set the index
field to true
in my schema. Which is
const usersSchema = new Schema({
username: {
type: String,
unique: true,
required: true
},
_id: {
type: String,
index: true,
default: shortid.generate
},
})
Though it is still working as expected but it just bother me when I see it on my console. Where I think there’s something wrong. But when I remove it or set to false
it is still working. The problem I have is that the unique validation doesn’t work.