20 lines
709 B
Python
20 lines
709 B
Python
from sqlalchemy.orm import Session, joinedload
|
|
|
|
def get_shipments(db: Session):
|
|
from app.models import Shipment
|
|
return db.query(Shipment).options(
|
|
joinedload(Shipment.contact_person),
|
|
joinedload(Shipment.return_address),
|
|
joinedload(Shipment.proposal),
|
|
joinedload(Shipment.dewars)
|
|
).all()
|
|
|
|
def get_shipment_by_id(db: Session, shipment_id: str):
|
|
from app.models import Shipment
|
|
shipment = db.query(Shipment).options(
|
|
joinedload(Shipment.contact_person),
|
|
joinedload(Shipment.return_address),
|
|
joinedload(Shipment.proposal),
|
|
joinedload(Shipment.dewars)
|
|
).filter(Shipment.shipment_id == shipment_id).first()
|
|
return shipment |