Firestore still isn’t convenient most of the time anyway, because all the fields have to be a
var
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.