Add project model, routes and logic. WIP

This commit is contained in:
Hannah dagemark 2026-08-06 18:26:24 +02:00
commit bbe0df9546
4 changed files with 76 additions and 1 deletions

View file

@ -0,0 +1,23 @@
from app.models.project import Project
from app.database import add_to_database, get_from_database, get_from_database_where, get_from_database_where_id
# 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 {"projects": get_from_database(Project)}
def get_by_id(project_id):
return {"project": get_from_database_where_id(Project, project_id)[0]}
def get_with_parent(project_id):
return {"projects": get_from_database_where(Project, Project.parent_id, project_id)}
def create(project: Project):
add_to_database(project)
return project