Dagemark-Backend/app/logic/project_logic.py
2026-08-06 22:54:49 +02:00

37 lines
1 KiB
Python

from app.database import (
add_to_database,
delete_from_database_where,
get_from_database,
get_from_database_where,
get_from_database_where_id,
)
from app.models.project import Project
# For now, this is a manifest for the project model architecture:
# A project consists of:
# ID (Autoincrement num, required),
# Parent (Num, optional, if this field contains a number (not none or 0), it is considered a child project of project with ID = num)
# Title (Required, text),
# Content (Optional, for now is string text but needs to store full Markdown including images in the future)
def get_all():
return get_from_database(Project)
def get_by_id(project_id: int):
return get_from_database_where_id(Project, project_id)
def get_with_parent(project_id: int):
return get_from_database_where(Project, Project.parent_id, project_id)
def create(project: Project):
add_to_database(project)
return project
def delete(project_id: int):
return delete_from_database_where(Project, Project.id, project_id)