Carter
05/16/2021, 5:35 PMvar
and ?
. For all my Firestore data, I ended up creating Model
for an immutable and non-null representation and a parallel CloudModel
with mutable and nullable representation for automatic Firestore serialization. I added companion functions to convert between the two, and that deals with specific differences (e.g. date representations).
It means some extra code, but it also means that Firebase limitations don’t propagate through my codebase and I get to be explicit about the conversion.
That’s the solution I ended up with, although I’d be curious if other good patterns have emerged.