I’ve recently been using Kmongo library and Kotlin together however I’ve made an issue on Kmongo but I’m unsure it is related to the library.
I’m trying to persist my data onto my mongo database (version 4.2.2)
data class Person(val firstname: String, val lastname: String){
val fullName
get() = "$lastname $firstname"
}
When I insert the data I sent only an object like this : val personData = Person("John", "Doe")
but when I do check on my mongo database
db.persons.find()
> { "_id" : ObjectId("5e2da298159243f9894d3834"), "firstname" : "John", "lastname" : "Doe", "fullName" : "Doe John" }
How can I prevent to get fullName
saved in my database ?
EDIT:
Insert code:
fun insertPerson(personData: Person): Person {
return userRepository.savePerson(personData)
}
With my Webservice I simply call this function where personData is the object I declared previously