from typing import Optional

from accounts.crud.base import CRUDBase
from accounts.models.account import Account
from accounts.schemas.account import AccountCreate, AccountUpdate
from sqlalchemy.orm import Session


class CRUDAccount(CRUDBase[Account, AccountCreate, AccountUpdate]):
    def get_by_doc_id(self, db: Session, *, doc_id: str) -> Optional[Account]:
        return db.query(self.model).filter(Account.doc_id == doc_id).first()


account = CRUDAccount(Account)