I’m trying to do a save on Mongo while doing a create. I want to throw an error if Duplicate key is found (this is a composite key for me). When I try to save the data with same composite key, somehow it works and does not throw error which is weird.
Hi @Pranita_Hatte and welcome to the MongoDB Community forums.
MongoDB should not be saving documents that violate a unique constraint. Can you share the index definition that has this constraint on it and then the documents that were inserted that have the same keys?
I was able to understand this. Mongo save is actually just updating the data and not doing the unique id check. I am also using CoroutineCrudRepository.