Documentation
¶
Overview ¶
Package adapter contains the identity bounded context's outbound adapters: pgx-backed implementations of the ports declared in identity/domain, run against the schema identity/migrate owns.
Every query schema-qualifies identity. explicitly rather than relying on search_path resolution, because callers connect with their own app's search path (see identity/migrate's package doc).
Index ¶
- type CredentialRepository
- type HouseholdRepository
- type MemberRepository
- func (r *MemberRepository) CreateMember(ctx context.Context, m *domain.Member) error
- func (r *MemberRepository) GetMember(ctx context.Context, id domain.MemberID) (*domain.Member, error)
- func (r *MemberRepository) ListMembers(ctx context.Context, householdID domain.HouseholdID) ([]*domain.Member, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CredentialRepository ¶
type CredentialRepository struct {
// contains filtered or unexported fields
}
CredentialRepository is the pgx-backed implementation of domain.CredentialRepository, backed by identity.member's own email and password_hash columns (see identity/migrate's baseline migration, not a separate credential table).
func NewCredentialRepository ¶
func NewCredentialRepository(dbtx db.TX) *CredentialRepository
NewCredentialRepository constructs the repository with an injected query executor. See HouseholdRepository's constructor doc for why the executor is a db.TX rather than a concrete pool type.
func (*CredentialRepository) FindByEmail ¶
func (r *CredentialRepository) FindByEmail(ctx context.Context, email string) (*domain.Credential, error)
FindByEmail returns the Credential for the given email address, or domain.ErrInvalidCredentials when no active member with that email and a non-null password_hash exists (preventing user enumeration). A deactivated member (identity.member.active = false) is excluded: login is one of the readers identity/migrate's package doc names for that flag.
func (*CredentialRepository) SetCredential ¶
func (r *CredentialRepository) SetCredential(ctx context.Context, memberID domain.MemberID, email, passwordHash string) error
SetCredential stores (or replaces) the email and password hash on the member row identified by memberID. Returns domain.ErrMemberNotFound when the member does not exist, and domain.ErrEmailAlreadyInUse when the email is already assigned to another member.
type HouseholdRepository ¶
type HouseholdRepository struct {
// contains filtered or unexported fields
}
HouseholdRepository is the pgx-backed implementation of domain.HouseholdRepository. UUIDs are passed and scanned as text, matching the identity schema's existing adapter convention (no pgx UUID codec registration).
func NewHouseholdRepository ¶
func NewHouseholdRepository(dbtx db.TX) *HouseholdRepository
NewHouseholdRepository constructs the repository with an injected query executor. The executor is a db.TX, satisfied by both *pgxpool.Pool (the default composition) and pgx.Tx (so a caller can run this repository inside its own transaction); the same methods work against either.
func (*HouseholdRepository) CreateHousehold ¶
CreateHousehold inserts a household and populates its timestamps.
func (*HouseholdRepository) GetHousehold ¶
func (r *HouseholdRepository) GetHousehold(ctx context.Context, id domain.HouseholdID) (*domain.Household, error)
GetHousehold returns the household, or domain.ErrHouseholdNotFound.
type MemberRepository ¶
type MemberRepository struct {
// contains filtered or unexported fields
}
MemberRepository is the pgx-backed implementation of domain.MemberRepository.
func NewMemberRepository ¶
func NewMemberRepository(dbtx db.TX) *MemberRepository
NewMemberRepository constructs the repository with an injected query executor. See HouseholdRepository's constructor doc for why the executor is a db.TX rather than a concrete pool type.
func (*MemberRepository) CreateMember ¶
CreateMember inserts a member, returning domain.ErrDuplicateMember when the display name collides (case-insensitively) within the household, and domain.ErrHouseholdNotFound when m.HouseholdID does not exist.
func (*MemberRepository) GetMember ¶
func (r *MemberRepository) GetMember(ctx context.Context, id domain.MemberID) (*domain.Member, error)
GetMember returns the member, or domain.ErrMemberNotFound.
func (*MemberRepository) ListMembers ¶
func (r *MemberRepository) ListMembers(ctx context.Context, householdID domain.HouseholdID) ([]*domain.Member, error)
ListMembers returns the household's members ordered by creation. An unknown household yields an empty slice, not an error.