from __future__ import annotations from datetime import datetime from eloquent import Model class Answer (Model): id: int query_id: int character: int content: str answer_type: int sent_at: datetime answered: bool __timestamps__ = False @property def query ( self, ) -> Query: return self.belongs_to (Query) class Query (Model): id: int user_id: int | None target_character: int content: str image_url: str | None query_type: int model: int sent_at: datetime answered: bool __timestamps__ = False @property def user ( self, ) -> User | None: return self.belongs_to (User) @property def answer_histories ( self, ) -> list[Answer]: return [x.answer for x in self.has_many (QueryAnswerHistory)] class QueryAnswerHistory (Model): id: int query_id: int answer_id: int @property def query ( self, ) -> Query: return self.belongs_to (Query) @property def answer ( self, ) -> Answer: return self.belongs_to (Answer) class User (Model): id: int platform: int code: str name: str icon: bytes