Files
location_service/app/repositories/property_repo.py
exolonConfidental a77788fc47 endpoint setup
2026-02-08 11:18:47 +05:30

20 lines
553 B
Python

from sqlalchemy import select
from sqlalchemy.orm import selectinload
from app.db.models.property import Property
class PropertyRepository:
@staticmethod
async def get_by_location_id(session, location_id: int):
stmt = (
select(Property)
.options(
selectinload(Property.owner),
selectinload(Property.location),
)
.where(Property.location_id == location_id)
)
result = await session.execute(stmt)
return result.scalar_one_or_none()