Atlas enforcing uniqueness when it shouldnt

Hi, I am using Atlas to store User data so have multiple documents in my collection. Most fields allow for repetitive data like name etc but when i try to enter a duplicate value in a particular field I get “An unexpected error occurred. Please try again later.” no further help is offered by mongo UI so I’m lost as to why this is.
I’m using mongoose on my server and there is no uniqueness enforcement on my side. when I try to enter in a value manually I get the error so its not at my end.

Is there any assistance available to solve this?

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.

Regards,
Stennie