How to get index name on duplicate document 11000 error?
See original GitHub issueHow can I get the index for which the error occurs with?
e.g. if my index is named email
, how do I get that from the err
object?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:18 (1 by maintainers)
Top Results From Across the Web
E11000 duplicate key error collection - MongoDB
I have an index in collection “persons” which shall avoid inserting duplicate documents with the same person name.
Read more >E11000 duplicate key error index in mongodb mongoose
The error message is saying that there's already a record with null as the email. In other words, you already have a user...
Read more >MongoError: E11000 duplicate key error collection
And once an index is set, it is there until you remove it, and the rule unique is still there also.
Read more >E11000 duplicate key error index in mongodb mongoose
The error message is saying that there is already a record with null as the email. If a document does not have a...
Read more >How To Use Indexes in MongoDB - DigitalOcean
MongoDB is a document-oriented database management system that allows you to ... "code" : 11000, "errmsg" : "E11000 duplicate key error ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is my RegExp solution to get index name with any type of error syntax I have found:
Here what I have tested:
Thanks to @paambaati I got the functionality I needed.
But is there a terser way to get the same result? //cc @vkarpov15