Implement BaseModel class, TimestampMixin, TzDateTime type; cleanup Task model
This commit is contained in:
parent
7ce43a2bfe
commit
252c15acbd
15 changed files with 223 additions and 42 deletions
|
|
@ -1,25 +1,19 @@
|
|||
from sqlalchemy import Column, Integer, String, Text
|
||||
from sqlalchemy import Column, String, Text
|
||||
|
||||
from tofu_api.common.database import Col
|
||||
from tofu_api.common.database.mixins import TimestampMixin
|
||||
from .base import BaseModel
|
||||
|
||||
|
||||
class Task(BaseModel):
|
||||
class Task(TimestampMixin, BaseModel):
|
||||
"""
|
||||
Database model for tasks.
|
||||
"""
|
||||
|
||||
__tablename__ = 'tasks'
|
||||
__tablename__ = 'task'
|
||||
|
||||
id: int = Column(Integer, nullable=False, primary_key=True)
|
||||
# TODO: created_at, modified_at
|
||||
title: Col[str] = Column(String(255), nullable=False)
|
||||
description: Col[str] = Column(Text, nullable=False, default='')
|
||||
|
||||
title: str = Column(String(255), nullable=False)
|
||||
description: str = Column(Text, nullable=False, default='')
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
# TODO: Implement a generic to_dict() in the base model
|
||||
return {
|
||||
'id': self.id,
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
}
|
||||
def __repr__(self):
|
||||
return self._repr(id=self.id, title=self.title)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue