Browse Source

#3 Added the models.

main
みてるぞ 1 month ago
parent
commit
01a52674ab
1 changed files with 63 additions and 0 deletions
  1. +63
    -0
      models.py

+ 63
- 0
models.py View File

@@ -0,0 +1,63 @@
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:
return self.belongs_to (User)

@property
def answer_histories (
self,
) -> list[QueryAnswerHistory]:
return self.has_many (QueryAnswerHistory)


class QueryAnswerHistory (Model):
id: int
query_id: int
answer_id: int


class User (Model):
id: int
platform: int
code: str
name: str
icon: bytes

Loading…
Cancel
Save