felicity-lims/felicity/database/entity.py

20 lines
447 B
Python
Raw Normal View History

2024-07-21 15:06:51 +08:00
from sqlalchemy import Column, String
from sqlalchemy.orm import DeclarativeBase
2024-07-21 21:44:22 +08:00
from sqlalchemy.ext.asyncio import AsyncAttrs
2024-07-21 15:06:51 +08:00
from core.uid_gen import get_flake_uid
2024-07-21 21:44:22 +08:00
class BaseEntity(DeclarativeBase, AsyncAttrs):
2024-07-21 15:06:51 +08:00
__name__: str
__abstract__ = True
__mapper_args__ = {"eager_defaults": True}
uid = Column(
String,
primary_key=True,
index=True,
nullable=False,
default=get_flake_uid,
)