Documentation
¶
Index ¶
- func NewAircraftRepository(db *sql.DB) repository.AircraftRepository
- func NewBackupDestinationRepository(db *sql.DB) repository.BackupDestinationRepository
- func NewBackupRunRepository(db *sql.DB) repository.BackupRunRepository
- func NewCredentialRepository(db *sql.DB) repository.CredentialRepository
- func NewCustomCurrencyRuleRepository(db *sql.DB) repository.CustomCurrencyRuleRepository
- func NewDeletionRepository(db *sql.DB) repository.DeletionRepository
- func NewDocumentFileRepository(db *sql.DB) repository.DocumentFileRepository
- func NewEmailDeliveryRepository(db *sql.DB) repository.EmailDeliveryRepository
- func NewEmailVerificationTokenRepository(db *sql.DB) repository.EmailVerificationTokenRepository
- func NewFlightBaselineRepository(db *sql.DB) repository.FlightBaselineRepository
- func NewFlightRepository(db *sql.DB) repository.FlightRepository
- func NewFlightSessionRepository(db *sql.DB) repository.FlightSessionRepository
- func NewFlightSignatureRepository(db *sql.DB) repository.FlightSignatureRepository
- func NewIdempotencyRepository(db *sql.DB) repository.IdempotencyRepository
- func NewLicenseRepository(db *sql.DB) repository.LicenseRepository
- func NewNotificationRepository(db *sql.DB) repository.NotificationRepository
- func NewOIDCIdentityRepository(db *sql.DB) repository.OIDCIdentityRepository
- func NewPasswordResetTokenRepository(db *sql.DB) repository.PasswordResetTokenRepository
- func NewRefreshTokenRepository(db *sql.DB) repository.RefreshTokenRepository
- func NewWebAuthnCredentialRepository(db *sql.DB) repository.WebAuthnCredentialRepository
- func NewWebAuthnSessionRepository(db *sql.DB) repository.WebAuthnSessionRepository
- type ClassRatingRepository
- func (r *ClassRatingRepository) Create(ctx context.Context, cr *models.ClassRating) error
- func (r *ClassRatingRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *ClassRatingRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.ClassRating, error)
- func (r *ClassRatingRepository) GetByLicenseID(ctx context.Context, licenseID uuid.UUID) ([]*models.ClassRating, error)
- func (r *ClassRatingRepository) Update(ctx context.Context, cr *models.ClassRating) error
- type ContactRepository
- func (r *ContactRepository) Create(ctx context.Context, contact *models.Contact) error
- func (r *ContactRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *ContactRepository) FindOrCreateByName(ctx context.Context, userID uuid.UUID, name string) (*models.Contact, bool, error)
- func (r *ContactRepository) GetByExactName(ctx context.Context, userID uuid.UUID, name string) (*models.Contact, error)
- func (r *ContactRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.Contact, error)
- func (r *ContactRepository) GetByUserID(ctx context.Context, userID uuid.UUID, updatedSince *time.Time) ([]*models.Contact, error)
- func (r *ContactRepository) RolesByContact(ctx context.Context, userID uuid.UUID) (map[uuid.UUID][]string, error)
- func (r *ContactRepository) Search(ctx context.Context, userID uuid.UUID, query string, limit int) ([]*models.Contact, error)
- func (r *ContactRepository) Update(ctx context.Context, contact *models.Contact) error
- func (r *ContactRepository) UpdateWithCrewRename(ctx context.Context, contact *models.Contact) (int, error)
- type FlightCrewRepository
- func (r *FlightCrewRepository) DeleteByFlightID(ctx context.Context, flightID uuid.UUID) error
- func (r *FlightCrewRepository) GetByFlightID(ctx context.Context, flightID uuid.UUID) ([]models.FlightCrewMember, error)
- func (r *FlightCrewRepository) GetByFlightIDs(ctx context.Context, flightIDs []uuid.UUID) (map[uuid.UUID][]models.FlightCrewMember, error)
- func (r *FlightCrewRepository) SetCrewMembers(ctx context.Context, flightID uuid.UUID, members []models.FlightCrewMember) error
- type UserRepository
- func (r *UserRepository) ConsumeRecoveryCode(ctx context.Context, id uuid.UUID, codeHash string) (bool, error)
- func (r *UserRepository) Create(ctx context.Context, user *models.User) error
- func (r *UserRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *UserRepository) DeleteUnverifiedRemindedBefore(ctx context.Context, remindedBefore time.Time) (int64, error)
- func (r *UserRepository) GetByEmail(ctx context.Context, email string) (*models.User, error)
- func (r *UserRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.User, error)
- func (r *UserRepository) IncrementFailedLoginAttempts(ctx context.Context, id uuid.UUID) error
- func (r *UserRepository) ListUnverifiedForReminder(ctx context.Context, createdBefore time.Time, limit int) ([]*models.User, error)
- func (r *UserRepository) LockAccount(ctx context.Context, id uuid.UUID, until time.Time) error
- func (r *UserRepository) MarkEmailVerified(ctx context.Context, id uuid.UUID) error
- func (r *UserRepository) MarkVerificationReminderSent(ctx context.Context, id uuid.UUID, at time.Time) error
- func (r *UserRepository) ResetFailedLoginAttempts(ctx context.Context, id uuid.UUID) error
- func (r *UserRepository) Update(ctx context.Context, user *models.User) error
- func (r *UserRepository) UpdateLastLogin(ctx context.Context, id uuid.UUID, at time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAircraftRepository ¶
func NewAircraftRepository(db *sql.DB) repository.AircraftRepository
func NewBackupDestinationRepository ¶ added in v1.2.4
func NewBackupDestinationRepository(db *sql.DB) repository.BackupDestinationRepository
NewBackupDestinationRepository returns a Postgres-backed repository for cloud backup destinations.
func NewBackupRunRepository ¶ added in v1.2.4
func NewBackupRunRepository(db *sql.DB) repository.BackupRunRepository
NewBackupRunRepository returns a Postgres-backed repository for backup runs.
func NewCredentialRepository ¶
func NewCredentialRepository(db *sql.DB) repository.CredentialRepository
func NewCustomCurrencyRuleRepository ¶ added in v1.3.1
func NewCustomCurrencyRuleRepository(db *sql.DB) repository.CustomCurrencyRuleRepository
NewCustomCurrencyRuleRepository creates a Postgres-backed repository for user-authored currency rules.
func NewDeletionRepository ¶ added in v1.3.2
func NewDeletionRepository(db *sql.DB) repository.DeletionRepository
NewDeletionRepository creates a repository over the tombstones written by the AFTER DELETE triggers in migration 000054. It is read-and-sweep only: nothing in Go ever inserts a tombstone, which is what keeps the record complete across the delete paths that bypass the repositories entirely.
func NewDocumentFileRepository ¶ added in v1.3.2
func NewDocumentFileRepository(db *sql.DB) repository.DocumentFileRepository
func NewEmailDeliveryRepository ¶ added in v1.3.2
func NewEmailDeliveryRepository(db *sql.DB) repository.EmailDeliveryRepository
NewEmailDeliveryRepository creates a new email delivery repository.
func NewEmailVerificationTokenRepository ¶ added in v1.2.5
func NewEmailVerificationTokenRepository(db *sql.DB) repository.EmailVerificationTokenRepository
NewEmailVerificationTokenRepository creates a new email verification token repository.
func NewFlightBaselineRepository ¶ added in v1.2.3
func NewFlightBaselineRepository(db *sql.DB) repository.FlightBaselineRepository
NewFlightBaselineRepository returns a postgres-backed FlightBaselineRepository.
func NewFlightRepository ¶
func NewFlightRepository(db *sql.DB) repository.FlightRepository
NewFlightRepository creates a new flight repository
func NewFlightSessionRepository ¶ added in v1.2.8
func NewFlightSessionRepository(db *sql.DB) repository.FlightSessionRepository
NewFlightSessionRepository returns a postgres-backed FlightSessionRepository.
func NewFlightSignatureRepository ¶ added in v1.2.9
func NewFlightSignatureRepository(db *sql.DB) repository.FlightSignatureRepository
NewFlightSignatureRepository returns a postgres-backed FlightSignatureRepository.
func NewIdempotencyRepository ¶ added in v1.3.2
func NewIdempotencyRepository(db *sql.DB) repository.IdempotencyRepository
NewIdempotencyRepository creates a new idempotency record repository.
func NewLicenseRepository ¶
func NewLicenseRepository(db *sql.DB) repository.LicenseRepository
NewLicenseRepository creates a new license repository
func NewNotificationRepository ¶
func NewNotificationRepository(db *sql.DB) repository.NotificationRepository
func NewOIDCIdentityRepository ¶ added in v1.3.2
func NewOIDCIdentityRepository(db *sql.DB) repository.OIDCIdentityRepository
NewOIDCIdentityRepository returns a repository.OIDCIdentityRepository backed by Postgres.
func NewPasswordResetTokenRepository ¶
func NewPasswordResetTokenRepository(db *sql.DB) repository.PasswordResetTokenRepository
NewPasswordResetTokenRepository creates a new password reset token repository
func NewRefreshTokenRepository ¶
func NewRefreshTokenRepository(db *sql.DB) repository.RefreshTokenRepository
NewRefreshTokenRepository creates a new refresh token repository
func NewWebAuthnCredentialRepository ¶ added in v1.2.0
func NewWebAuthnCredentialRepository(db *sql.DB) repository.WebAuthnCredentialRepository
NewWebAuthnCredentialRepository creates a new WebAuthn credential repository.
func NewWebAuthnSessionRepository ¶ added in v1.2.0
func NewWebAuthnSessionRepository(db *sql.DB) repository.WebAuthnSessionRepository
NewWebAuthnSessionRepository creates a new WebAuthn session repository.
Types ¶
type ClassRatingRepository ¶
type ClassRatingRepository struct {
// contains filtered or unexported fields
}
func NewClassRatingRepository ¶
func NewClassRatingRepository(db *sql.DB) *ClassRatingRepository
func (*ClassRatingRepository) Create ¶
func (r *ClassRatingRepository) Create(ctx context.Context, cr *models.ClassRating) error
func (*ClassRatingRepository) GetByID ¶
func (r *ClassRatingRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.ClassRating, error)
func (*ClassRatingRepository) GetByLicenseID ¶
func (r *ClassRatingRepository) GetByLicenseID(ctx context.Context, licenseID uuid.UUID) ([]*models.ClassRating, error)
func (*ClassRatingRepository) Update ¶
func (r *ClassRatingRepository) Update(ctx context.Context, cr *models.ClassRating) error
type ContactRepository ¶
type ContactRepository struct {
// contains filtered or unexported fields
}
func NewContactRepository ¶
func NewContactRepository(db *sql.DB) *ContactRepository
func (*ContactRepository) FindOrCreateByName ¶ added in v1.3.3
func (r *ContactRepository) FindOrCreateByName(ctx context.Context, userID uuid.UUID, name string) (*models.Contact, bool, error)
FindOrCreateByName returns the user's contact with this name, creating it if there is none, and reports whether it created one.
The read-then-insert is deliberately racy-tolerant rather than racy: two concurrent crew writes for the same new name both miss the SELECT, one INSERT wins, and the loser's ON CONFLICT DO NOTHING returns no row and falls through to the second lookup. Without idx_contacts_user_lower_name backing the conflict target this collapses back into a plain read-then-write and duplicates reappear.
The caller is responsible for trimming; the name is matched and stored verbatim.
func (*ContactRepository) GetByExactName ¶
func (*ContactRepository) GetByUserID ¶
func (*ContactRepository) RolesByContact ¶ added in v1.3.3
func (r *ContactRepository) RolesByContact(ctx context.Context, userID uuid.UUID) (map[uuid.UUID][]string, error)
RolesByContact returns the distinct crew roles each of the user's contacts has been logged in, so an export can say that someone is an instructor without the caller walking every flight.
func (*ContactRepository) UpdateWithCrewRename ¶ added in v1.3.3
func (r *ContactRepository) UpdateWithCrewRename(ctx context.Context, contact *models.Contact) (int, error)
UpdateWithCrewRename updates the contact and carries a name change into the crew rows that reference it, returning how many crew rows were rewritten. contact.UserID must be set by the caller.
flight_crew_members.name is denormalised: it is the name as logged, and it is what exports and PIC-of-record resolution read. Leaving it behind on a rename means correcting a typo in the address book fixes nothing in the logbook, while rewriting it everywhere would mutate entries an instructor has already attested. So the rename stops at the signature boundary, exactly as the aircraft-registration rename does.
type FlightCrewRepository ¶
type FlightCrewRepository struct {
// contains filtered or unexported fields
}
func NewFlightCrewRepository ¶
func NewFlightCrewRepository(db *sql.DB) *FlightCrewRepository
func (*FlightCrewRepository) DeleteByFlightID ¶
func (*FlightCrewRepository) GetByFlightID ¶
func (r *FlightCrewRepository) GetByFlightID(ctx context.Context, flightID uuid.UUID) ([]models.FlightCrewMember, error)
func (*FlightCrewRepository) GetByFlightIDs ¶ added in v1.2.3
func (r *FlightCrewRepository) GetByFlightIDs(ctx context.Context, flightIDs []uuid.UUID) (map[uuid.UUID][]models.FlightCrewMember, error)
GetByFlightIDs batch-loads crew members for multiple flights and returns them grouped by flight ID. Used by exporters to avoid N+1 queries when rendering many flights.
func (*FlightCrewRepository) SetCrewMembers ¶
func (r *FlightCrewRepository) SetCrewMembers(ctx context.Context, flightID uuid.UUID, members []models.FlightCrewMember) error
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
func NewUserRepository ¶
func NewUserRepository(db *sql.DB) *UserRepository
func (*UserRepository) ConsumeRecoveryCode ¶ added in v1.3.1
func (r *UserRepository) ConsumeRecoveryCode(ctx context.Context, id uuid.UUID, codeHash string) (bool, error)
ConsumeRecoveryCode atomically removes one recovery code hash from the user's list, returning true only if this call was the one that removed it.
The previous read-modify-write (load user, drop the matching entry in Go, write the whole row back) had no lock or version check, so concurrent submissions of the SAME code all observed it as present, all matched, and all authenticated. Confirmed: ten parallel /auth/2fa/login requests with one code returned 200 ten times. array_remove inside a single conditional UPDATE makes consumption atomic -- the WHERE clause fails for every caller after the first, and 0 rows affected means "already used".
func (*UserRepository) DeleteUnverifiedRemindedBefore ¶ added in v1.3.2
func (*UserRepository) GetByEmail ¶
func (*UserRepository) IncrementFailedLoginAttempts ¶
func (*UserRepository) ListUnverifiedForReminder ¶ added in v1.3.2
func (*UserRepository) LockAccount ¶
func (*UserRepository) MarkEmailVerified ¶ added in v1.2.5
func (*UserRepository) MarkVerificationReminderSent ¶ added in v1.3.2
func (*UserRepository) ResetFailedLoginAttempts ¶
func (*UserRepository) UpdateLastLogin ¶ added in v1.3.2
UpdateLastLogin stamps the moment a session was handed out. Missing rows are not an error: the caller has already authenticated, and failing the login because the stamp could not be written would be worse than a stale timestamp.
Source Files
¶
- aircraft.go
- backup_destination.go
- backup_run.go
- class_rating.go
- contact.go
- credential.go
- custom_currency.go
- deletion.go
- document_file.go
- email_delivery.go
- email_verification_token.go
- flight.go
- flight_baseline.go
- flight_crew.go
- flight_session.go
- flight_signature.go
- idempotency.go
- license.go
- notification.go
- oidc.go
- password_reset_token.go
- refresh_token.go
- updated_since.go
- user.go
- webauthn.go