modify structure
This commit is contained in:
BIN
server/src/app/models/__pycache__/knowledge.cpython-311.pyc
Normal file
BIN
server/src/app/models/__pycache__/knowledge.cpython-311.pyc
Normal file
Binary file not shown.
BIN
server/src/app/models/__pycache__/metric.cpython-311.pyc
Normal file
BIN
server/src/app/models/__pycache__/metric.cpython-311.pyc
Normal file
Binary file not shown.
BIN
server/src/app/models/__pycache__/question.cpython-311.pyc
Normal file
BIN
server/src/app/models/__pycache__/question.cpython-311.pyc
Normal file
Binary file not shown.
9
server/src/app/models/knowledge.py
Normal file
9
server/src/app/models/knowledge.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from sqlmodel import Field, SQLModel, Relationship
|
||||
#TODO : add pydantic validation
|
||||
|
||||
class Knowledge(SQLModel, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
content: str = Field(index=True)
|
||||
uri: str = Field(index=True)
|
||||
|
||||
questions: list["Question"] = Relationship(back_populates="knowledge", cascade_delete=True) # type: ignore
|
||||
12
server/src/app/models/metric.py
Normal file
12
server/src/app/models/metric.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from sqlmodel import Field, SQLModel, Relationship
|
||||
from src.app.models.question import Question
|
||||
|
||||
#TODO : add pydantic validation
|
||||
|
||||
class Metric(SQLModel, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
|
||||
question_id: int | None = Field(default=None, foreign_key="question.id", ondelete="CASCADE")
|
||||
question: Question | None = Relationship(back_populates="metrics")
|
||||
|
||||
need_index: int
|
||||
12
server/src/app/models/question.py
Normal file
12
server/src/app/models/question.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from sqlmodel import Field, SQLModel, Relationship
|
||||
from src.app.models.knowledge import Knowledge
|
||||
#TODO : add pydantic validation
|
||||
|
||||
class Question(SQLModel, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
question:str
|
||||
|
||||
knowledge_id: int | None = Field(default=None, foreign_key="knowledge.id", ondelete="CASCADE")
|
||||
knowledge: Knowledge | None = Relationship(back_populates="questions")
|
||||
|
||||
metrics: list["Metric"] = Relationship(back_populates="question", cascade_delete=True) # type: ignore
|
||||
Reference in New Issue
Block a user