(organizationId: string)
| 381 | * silently fallen back to the caller's identity. |
| 382 | */ |
| 383 | export async function getOrganizationOwnerId(organizationId: string): Promise<string | null> { |
| 384 | const [ownerMembership] = await db |
| 385 | .select({ userId: member.userId }) |
| 386 | .from(member) |
| 387 | .where(and(eq(member.organizationId, organizationId), eq(member.role, 'owner'))) |
| 388 | .limit(1) |
| 389 | |
| 390 | return ownerMembership?.userId ?? null |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Like `getOrganizationOwnerId` but throws when no owner row exists. |
no test coverage detected