Models API#
fastapi_restly.models provides the SQLAlchemy declarative base classes and
mixins (DataclassBase, IDBase, IDMixin, TimestampsMixin) that
Restly models are declared against.
- class fastapi_restly.models.DataclassBase(**kwargs: Any)#
Bases:
AsyncAttrs,TableNameMixin,MappedAsDataclass,DeclarativeBaseSQLAlchemy declarative base with dataclass semantics.
AsyncAttrsaddsawaitable_attrs, so an unloaded attribute can be reached from plain async code –await obj.awaitable_attrs.items– where a bareobj.itemswould raiseMissingGreenlet. Views eager-load what the response schema names, so this is for the code that runs outside that: anafter_commithook, a custom business method.- registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>#
Refers to the
_orm.registryin use where new_orm.Mapperobjects will be associated.
- type_annotation_map = {<enum 'Enum'>: Enum(native_enum=False, length=64)}#
- class fastapi_restly.models.IDBase(*, id: int = <sqlalchemy.orm.properties.MappedColumn object>)#
Bases:
IDMixin,DataclassBaseConvenience base: DataclassBase + integer id primary key.
- class fastapi_restly.models.IDMixin(*, id: int = <sqlalchemy.orm.properties.MappedColumn object>)#
Bases:
MappedAsDataclassDataclass mixin adding an auto-incrementing integer id primary key.
- class fastapi_restly.models.TimestampsMixin(*, created_at: ~datetime.datetime = <sqlalchemy.orm.properties.MappedColumn object>, updated_at: ~datetime.datetime = <sqlalchemy.orm.properties.MappedColumn object>)#
Bases:
MappedAsDataclassDataclass mixin adding UTC-aware created_at and updated_at timestamps.
See also
Getting Started discusses choosing between your own DeclarativeBase and the convenience bases.