What is Nostr?
ismyhc
npub1ch8…zh48
2024-07-31 14:04:45
in reply to nevent1q…590u

ismyhc on Nostr: I haven't used value transformers before. Im going to look into them though. Right ...

I haven't used value transformers before. Im going to look into them though.

Right now I have a handful of models that I create from events as they come in, then store them into SwiftData, but that code is getting overly complicated. So before I dig too deep Im experimenting with something that may or may not work.

Instead of having all these different SwiftData models, Im simply storing a single model for the event. Almost as it would be stored on a relay. One addition to the model is that I serialize the tags into a single special formatted string since trying to use a predicate on nested arrays might get messy.

The idea is that this keeps my data model more simple as well as code path where I store these events.

Then I will use the queries to map the stored event's into their more detailed object where needed.

The unknown I have now is if doing this will cause too much overhead on the UI. I just don't know yet, but my code is early enough that I can try it and if it works as I hope it does it simplifies the code around this a lot.
Author Public Key
npub1ch8a4xxsru2jkdynmx27a4xdknv72k5h8yjld702y3mf5k3puauqmszh48