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