Welcome to the MongoDB Community Forums @Shaw_O_Donnell!
An unexpected error occurred. Please try again later” suggests there is an unhandled exception in your Node.js application code – this message comes from an application server, not from the MongoDB driver.
Have you tried printing out the details of the exception?
Please provide some more information to help understand your issue:
- Exact error message returned by your Mongoose code
- Snippet of code showing the update that results in the error message
- Version of Mongoose used
If there is a duplicate key exception, please check the output of
db.collection.getIndexes() for this collection in the MongoDB shell. One possibility is that you added a
unique index at some point in the past, but removed the
unique property from your Mongoose model without recreating the index in your cluster.
By default Mongoose does not check that existing indexes match options in your model code. There is a
Model.syncIndexes() function which helps with reconciliation, but I would be cautious using this outside of a development environment. Dropping and recreating indexes in production could have a significant performance impact.