Mongo 和 Kotlin 的委托问题

Delegate issue with Mongo and Kotlin

我最近一直在同时使用 Kmongo library 和 Kotlin,但是我在 Kmongo 上提出了一个问题,但我不确定它是否与库有关。

我正在尝试将我的数据保存到我的 mongo 数据库(版本 4.2.2)

@Serializable
data class Person(val firstname: String, val lastname: String){

   val fullName
     get() = "$lastname $firstname"
}

当我插入数据时,我只发送了一个这样的对象:val person = Person("John", "Doe") 但是当我检查我的 mongo 数据库时

db.persons.find()
> { "_id" : ObjectId("5e2da298159243f9894d3834"), "firstname" : "John", "lastname" : "Doe", "fullName" : "Doe John" }

如何防止 fullName 保存在我的数据库中?

编辑:

我尝试在我的变量上使用 @Transient 注释,但没有用,我收到一条检查消息说:Property does not have backing field which makes it non-serializable and therefore @Transient is redundant

使用@Transient注释:

@Transient
val fullName
  get() = "$lastname $firstname"

今天,Kmongo 库在后台使用 Jackson,为了避免 属性 被解析,我不得不使用:https://www.concretepage.com/jackson-api/jackson-jsonignore-jsonignoreproperties-and-jsonignoretype

所以我的数据 class 的代码现在是:

@Serialiable
@JsonIgnoreProperties("fullName")
data class Person(...