Get an organization by ID with relationships preloaded.
(cls, orm: orm.Session, org_id: str | UUID)
| 320 | |
| 321 | @classmethod |
| 322 | def get_by_id(cls, orm: orm.Session, org_id: str | UUID) -> Optional['OrgModel']: |
| 323 | """Get an organization by ID with relationships preloaded.""" |
| 324 | return ( |
| 325 | orm.query(cls) |
| 326 | .options( |
| 327 | joinedload(cls.users), |
| 328 | joinedload(cls.invites), |
| 329 | joinedload(cls.projects), |
| 330 | ) |
| 331 | .filter(cls.id == normalize_uuid(org_id)) |
| 332 | .first() |
| 333 | ) |
| 334 | |
| 335 | @classmethod |
| 336 | def get_all_for_user(cls, orm: orm.Session, user_id: str | UUID) -> Optional[list['OrgModel']]: |