Update app/crud.py

This commit is contained in:
Cameron 2025-12-10 22:55:19 +00:00
parent d8ef3694aa
commit 53ab4ffd5e

View file

@ -1,11 +1,21 @@
from sqlalchemy.orm import Session
from app import models
from typing import List
def get_customers(db: Session):
# ---- Customers ----
def get_customers(db: Session) -> List[models.Customer]:
return db.query(models.Customer).all()
def get_accounts(db: Session):
return db.query(models.Account).all()
# ---- Accounts ----
def get_accounts(db: Session, customer_id: int = None) -> List[models.Account]:
query = db.query(models.Account)
if customer_id is not None:
query = query.filter(models.Account.customer_id == customer_id)
return query.all()
def get_transactions(db: Session):
return db.query(models.Transactions).all()
# ---- Transactions ----
def get_transactions(db: Session, account_id: str = None) -> List[models.Transaction]:
query = db.query(models.Transaction)
if account_id is not None:
query = query.filter(models.Transaction.account_id == account_id)
return query.all()