firedantic
firedantic copied to clipboard
Support "omit empty"
Golang firestore library supports the ability to tag fields as omitempty meaning they will not get stored in the DB when not set. This could be done via e.g. combining Optional with a Config option like
class Model(AsyncModel):
field: Optional[str]
another: Optional[List[int]]
# ...
class Config:
omitempty = "*"
# or
omitempty = ["field", "another"]
Alternatively e.g. by extending Field() or similar from pydantic
Pydantic dict() and json(), or the corresponding model_dump() in v2, support the param:
exclude_unset: Whether to exclude fields that are unset or None from the output.
So maybe Firedantic save() could have it similarily easily.
But I agree that model conf for it would be nice.