32 lines
913 B
Python
32 lines
913 B
Python
from app.database import (
|
|
add_to_database,
|
|
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
|