Skip to content

Commit

Permalink
add get_parents_lists_by_school_id route
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTraveylan committed Aug 28, 2024
1 parent 3ff1d85 commit 6442199
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/api/parents_list/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional

from pydantic import field_validator
from sqlalchemy import Column, ForeignKey, Integer
from sqlmodel import Field
from sqlalchemy import Column, ForeignKey, Integer, select
from sqlmodel import Field, Session

from app.commun.validator import validate_string
from app.database.model_base import BaseSQLModel
Expand Down Expand Up @@ -30,5 +30,12 @@ def list_name_format(cls, value: str) -> str:
class ParentsListService(Repository[ParentsList]):
__model__ = ParentsList

def get_all_by_school_id(
self, session: Session, school_id: int
) -> list[ParentsList]:
statement = select(ParentsList).where(ParentsList.school_id == school_id)

return [item[0] for item in session.exec(statement).all()]


PARENTS_LIST_SERVICE = ParentsListService()

0 comments on commit 6442199

Please sign in to comment.