Is there a way, like an annotation, that prevents a property from being written in the database without also preventing it from being serialized as a Ktor JSON response?
data class Bank(
@BsonId @JsonProperty("_id") val id: Id<Bank> = newId(),
var name: String,
var initialAmount: Double = 0.0,
@JsonIgnore var currentAmount: Double?
)
In the example above, by adding @JsonIgnore, I'm disabling the currentAmount property serialization for the whole project, not only for KMongo.
I also know that I could disable null values from being persisted, but that's not something that I'm willing to do. I'm wondering if there is a way to exclude a property, regardless of the state, from the "mongo schema" without changing the whole serialization.
In this case, I'm using Jackson as the serialization provider.
Is there a way, like an annotation, that prevents a property from being written in the database without also preventing it from being serialized as a Ktor JSON response?
In the example above, by adding
@JsonIgnore
, I'm disabling thecurrentAmount
property serialization for the whole project, not only for KMongo.I also know that I could disable null values from being persisted, but that's not something that I'm willing to do. I'm wondering if there is a way to exclude a property, regardless of the state, from the "mongo schema" without changing the whole serialization.
In this case, I'm using Jackson as the serialization provider.