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

Cannot create an index #5782

Closed
erassynathingo opened this issue Nov 2, 2017 · 6 comments
Closed

Cannot create an index #5782

erassynathingo opened this issue Nov 2, 2017 · 6 comments
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity

Comments

@erassynathingo
Copy link

Hi, I cannot add anything to my database using mongoose.. its gives me this error
"Unhandled rejection MongoError: Cannot create an index on collection.name with an insert to 59bfc8c4970199306ad8914f_collection.system.indexes"
and this "E11000 duplicate key error collection: collection.name index: id"

I am pretty sure there is nothing in the database, i even deleted the collection..same error. please help

using mongoose 4.12.6 & node v8.6.0

@vkarpov15
Copy link
Collaborator

Can you please provide more substantial code samples and error stack traces? Better yet, please just follow the issue template.

@vkarpov15 vkarpov15 added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Nov 2, 2017
@erassynathingo
Copy link
Author

attached my basic CRUD functions, model and model class...and the error stack trace image
error stack trace

model

model creator class

crud functions

@vkarpov15
Copy link
Collaborator

Which version of mongodb are you using?

@dworrad
Copy link

dworrad commented Nov 14, 2017

Same issue here... I first got this issue when switching to Atlas

@dworrad
Copy link

dworrad commented Nov 15, 2017

I believe if you remove the unique: true from your _id field the error will go away.

@vkarpov15
Copy link
Collaborator

Yeah @dworrad is right. The issue is that you set unique: true on _id. You shouldn't do that, it'll cause index builds to fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants