Source code for election_day.collections.candidates

from onegov.election_day.models import Candidate


from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from sqlalchemy.orm import Query, Session
    from uuid import UUID


[docs] class CandidateCollection: def __init__(self, session: 'Session'):
[docs] self.session = session
[docs] def query(self) -> 'Query[Candidate]': return self.session.query(Candidate)
[docs] def by_id(self, id: 'UUID') -> Candidate | None: return self.query().filter(Candidate.id == id).first()