Added the Services layer to the code to do the database operation

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-06-05 13:28:16 -03:00
parent 0a9c2952ec
commit 8ad57b548f
7 changed files with 129 additions and 0 deletions
+10
View File
@@ -1,3 +1,5 @@
from typing import Any
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
@@ -16,3 +18,11 @@ class Entry(Base):
secondary=photo_entry_association,
back_populates="entries")
fk_TravelDiary_id = Column(Integer, ForeignKey("TravelDiary.id"))
def __init__(self, title: str, text: str, date: str, travel_diary_id: int, **kw: Any):
super().__init__(**kw)
self.title = title
self.text = text
self.date = date
self.fk_TravelDiary_id = travel_diary_id
+6
View File
@@ -1,3 +1,5 @@
from typing import Any
from sqlalchemy import Column, String, Integer
from ..database import Base
@@ -6,3 +8,7 @@ class TravelDiary(Base):
__tablename__ = "TravelDiary"
id = Column(Integer, primary_key=True)
name = Column(String)
def __init__(self, name: str, **kw: Any):
super().__init__(**kw)
self.name = name