MongoDB exception DuplicateKey while saving
I have a simple method to update my object
fun updateUniversity(university: University): Mono {
if (university.id == null) {
return Mono.empty()
}
return universityRepository
.findById(university.id!!)
.filter { it.name == university.name }
.map { university.copy() }
.flatMap { universityRepository.save(it) }
}
and it fails on saving the result (org.springframework.dao.DuplicateKeyException). But saving is not only about creating...