import typing as t

from sqlmodel import SQLModel, Field, Relationship
from datetime import datetime

from .discussions import DB_Discussion



class DB_Post(SQLModel, table=True):
    __tablename__ = 'posts'
    id: t.Optional[int] = Field(default=None, primary_key=True)
    """The ID of the post. This is handled by the database."""

    discussion_id: int = Field(foreign_key='discussions.id')
    discussion: t.Optional[DB_Discussion] = Relationship(back_populates='posts')
    """Discussion that this post belongs to."""

    number: int = 