package postgres import ( "context" "github.com/jackc/pgx/v5/pgtype" "github.com/samcharles93/archie-core/internal/domain/org" ) // scopeOrg is the org a request's reads are confined to, or NULL for an // internal service acting across orgs. func scopeOrg(ctx context.Context) pgtype.Text { id, ok := org.Scope(ctx) return pgtype.Text{String: string(id), Valid: ok} } // memberScope is the org whose members and agents a read is confined to, or // NULL when the request may read the whole instance. func memberScope(ctx context.Context) pgtype.Text { if org.InstanceScope(ctx) { return pgtype.Text{} } return scopeOrg(ctx) }