Hi!
I am trying to switch from litote kmongo to the native kotlin coroutines. I have two issues with switching that I cannot seem to solve, both are connected to serialization:
- how do I ignore fields upon inserting/upserting?
in kmongo I used the trick to first turn my object via jackson into json, then deserialized into a Document, removed all fields that I needed to exclude, and then sent it to the collection.
But I don’t see a way to turn my objects into json without Jackson.
Note: I need the BsonProperties-Annotation for all properties, because our DB is served by another team and comes from SQL, so this is all UPPERCASE_WITH_UNDERSCORES which needs transforming into nice kotlin field names. But I don’t see a possibility to turn my object into the actual form it will be sent in (with the terrible casing) and the BsonIgnore-Annotation is also not accepted by the code. So what do I do?
- How can I log out specific objects in the serialized form they are sent to the DB when needed? With just @BsonProperty annotations I get my field names but not the actual names as in the DB.In short: How do I turn my objects into Documents and/or Json in the actual serialized format?
(And please: I am not going to implement a Document() → addField for each field of each model class. This should be easy. I am sure you have a way. I just haven’t found it yet. Right???)
PS: These are the annotations I am using for my serialization/deserialization I was thinking about solving both via jackson, but then I would have to have double the annotations for each model class field, like in the example in the link for the deviceType field I would need
@BsonProperty("type") @JsonProperty("type") val deviceType: String
which means a whole lot of duplication
Any solutions to either problem is very much appreciated!