I solved it but I will put it here nevertheless in case someone stumbles on it someday.
I was keeping on having E11000 duplicate key error collection after having changed my schema. Upon adding a document to the DB, if it was the first one it was alright, but then all the following would cause this error.
The problem was caused by the fact that I had changed the name of a key in my model, so the collection, without me knowing apparently, stored this value as null because I didn’t specify it anymore. And because it was supposed to be unique, when I added another document, it added another null to this “ghost” key. The solution was to drop the collection and start anew and it worked wonders.
Hope this helps !
Dimitri Lazarevic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1