repositories

package
v2.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountRepository

type AccountRepository interface {
	GetByID(ctx context.Context, id string) (*models.Account, error)
	GetByUserID(ctx context.Context, userID string) (*models.Account, error)
	GetByUserIDAndProvider(ctx context.Context, userID string, provider string) (*models.Account, error)
	GetByProviderAndAccountID(ctx context.Context, provider string, accountID string) (*models.Account, error)
	Create(ctx context.Context, account *models.Account) (*models.Account, error)
	Update(ctx context.Context, account *models.Account) (*models.Account, error)
	UpdateFields(ctx context.Context, userID string, fields map[string]any) error
	WithTx(tx bun.IDB) AccountRepository
}

func NewBunAccountRepository

func NewBunAccountRepository(db bun.IDB) AccountRepository

type BunAccountRepository

type BunAccountRepository struct {
	// contains filtered or unexported fields
}

func (*BunAccountRepository) Create

func (r *BunAccountRepository) Create(ctx context.Context, account *models.Account) (*models.Account, error)

func (*BunAccountRepository) GetByID

func (r *BunAccountRepository) GetByID(ctx context.Context, id string) (*models.Account, error)

func (*BunAccountRepository) GetByProviderAndAccountID

func (r *BunAccountRepository) GetByProviderAndAccountID(ctx context.Context, provider, accountID string) (*models.Account, error)

func (*BunAccountRepository) GetByUserID

func (r *BunAccountRepository) GetByUserID(ctx context.Context, userID string) (*models.Account, error)

func (*BunAccountRepository) GetByUserIDAndProvider

func (r *BunAccountRepository) GetByUserIDAndProvider(ctx context.Context, userID, provider string) (*models.Account, error)

func (*BunAccountRepository) Update

func (r *BunAccountRepository) Update(ctx context.Context, account *models.Account) (*models.Account, error)

func (*BunAccountRepository) UpdateFields

func (r *BunAccountRepository) UpdateFields(ctx context.Context, userID string, fields map[string]any) error

func (*BunAccountRepository) WithTx

type BunSessionRepository

type BunSessionRepository struct {
	// contains filtered or unexported fields
}

func (*BunSessionRepository) Create

func (r *BunSessionRepository) Create(ctx context.Context, session *models.Session) (*models.Session, error)

func (*BunSessionRepository) Delete

func (r *BunSessionRepository) Delete(ctx context.Context, id string) error

func (*BunSessionRepository) DeleteByUserID

func (r *BunSessionRepository) DeleteByUserID(ctx context.Context, userID string) error

func (*BunSessionRepository) DeleteExpired added in v2.10.0

func (r *BunSessionRepository) DeleteExpired(ctx context.Context) error

func (*BunSessionRepository) DeleteOldestByUserID added in v2.10.0

func (r *BunSessionRepository) DeleteOldestByUserID(ctx context.Context, userID string, maxCount int) error

func (*BunSessionRepository) GetByID

func (r *BunSessionRepository) GetByID(ctx context.Context, id string) (*models.Session, error)

func (*BunSessionRepository) GetByToken

func (r *BunSessionRepository) GetByToken(ctx context.Context, token string) (*models.Session, error)

func (*BunSessionRepository) GetByUserID

func (r *BunSessionRepository) GetByUserID(ctx context.Context, userID string) (*models.Session, error)

func (*BunSessionRepository) GetDistinctUserIDs added in v2.9.0

func (r *BunSessionRepository) GetDistinctUserIDs(ctx context.Context) ([]string, error)

func (*BunSessionRepository) Update

func (r *BunSessionRepository) Update(ctx context.Context, session *models.Session) (*models.Session, error)

func (*BunSessionRepository) WithTx

type BunUserRepository

type BunUserRepository struct {
	// contains filtered or unexported fields
}

func (*BunUserRepository) Create

func (r *BunUserRepository) Create(ctx context.Context, user *models.User) (*models.User, error)

func (*BunUserRepository) GetByEmail

func (r *BunUserRepository) GetByEmail(ctx context.Context, email string) (*models.User, error)

func (*BunUserRepository) GetByID

func (r *BunUserRepository) GetByID(ctx context.Context, id string) (*models.User, error)

func (*BunUserRepository) Update

func (r *BunUserRepository) Update(ctx context.Context, user *models.User) (*models.User, error)

func (*BunUserRepository) UpdateFields

func (r *BunUserRepository) UpdateFields(ctx context.Context, id string, fields map[string]any) error

func (*BunUserRepository) WithTx

func (r *BunUserRepository) WithTx(tx bun.IDB) UserRepository

type BunVerificationRepository

type BunVerificationRepository struct {
	// contains filtered or unexported fields
}

func (*BunVerificationRepository) Create

func (*BunVerificationRepository) Delete

func (*BunVerificationRepository) DeleteByUserIDAndType

func (r *BunVerificationRepository) DeleteByUserIDAndType(ctx context.Context, userID string, vType models.VerificationType) error

func (*BunVerificationRepository) DeleteExpired added in v2.10.0

func (r *BunVerificationRepository) DeleteExpired(ctx context.Context) error

func (*BunVerificationRepository) GetByID

func (*BunVerificationRepository) GetByToken

func (*BunVerificationRepository) WithTx

type CryptoTokenRepositoryImpl

type CryptoTokenRepositoryImpl struct {
	// contains filtered or unexported fields
}

CryptoTokenRepositoryImpl implements TokenRepository using modern crypto

func (*CryptoTokenRepositoryImpl) Decrypt

func (r *CryptoTokenRepositoryImpl) Decrypt(encrypted string) (string, error)

Decrypt decrypts a token

func (*CryptoTokenRepositoryImpl) Encrypt

func (r *CryptoTokenRepositoryImpl) Encrypt(token string) (string, error)

Encrypt encrypts a token Format: base64url([nonce_24][ciphertext+tag])

func (*CryptoTokenRepositoryImpl) Generate

func (r *CryptoTokenRepositoryImpl) Generate() (string, error)

Generate generates a random 256-bit token encoded as hex

func (*CryptoTokenRepositoryImpl) Hash

func (r *CryptoTokenRepositoryImpl) Hash(token string) string

Hash creates a SHA256 hash of the token (for DB storage)

type SessionRepository

type SessionRepository interface {
	GetByID(ctx context.Context, id string) (*models.Session, error)
	GetByToken(ctx context.Context, token string) (*models.Session, error)
	GetByUserID(ctx context.Context, userID string) (*models.Session, error)
	Create(ctx context.Context, session *models.Session) (*models.Session, error)
	Update(ctx context.Context, session *models.Session) (*models.Session, error)
	Delete(ctx context.Context, id string) error
	DeleteByUserID(ctx context.Context, userID string) error
	DeleteExpired(ctx context.Context) error
	DeleteOldestByUserID(ctx context.Context, userID string, maxCount int) error
	GetDistinctUserIDs(ctx context.Context) ([]string, error)
	WithTx(tx bun.IDB) SessionRepository
}

func NewBunSessionRepository

func NewBunSessionRepository(db bun.IDB) SessionRepository

type TokenRepository

type TokenRepository interface {
	Generate() (string, error)
	Hash(token string) string
	Encrypt(token string) (string, error)
	Decrypt(encrypted string) (string, error)
}

func NewCryptoTokenRepository

func NewCryptoTokenRepository(secret string) TokenRepository

NewCryptoTokenRepository creates a new crypto token repository secret must be at least 32 bytes of high-entropy data

type Transaction

type Transaction interface{}

Transaction represents a database transaction interface

type UserRepository

type UserRepository interface {
	GetByID(ctx context.Context, id string) (*models.User, error)
	GetByEmail(ctx context.Context, email string) (*models.User, error)
	Create(ctx context.Context, user *models.User) (*models.User, error)
	Update(ctx context.Context, user *models.User) (*models.User, error)
	UpdateFields(ctx context.Context, id string, fields map[string]any) error
	WithTx(tx bun.IDB) UserRepository
}

func NewBunUserRepository

func NewBunUserRepository(db bun.IDB) UserRepository

type VerificationRepository

type VerificationRepository interface {
	GetByID(ctx context.Context, id string) (*models.Verification, error)
	GetByToken(ctx context.Context, token string) (*models.Verification, error)
	Create(ctx context.Context, verification *models.Verification) (*models.Verification, error)
	Delete(ctx context.Context, id string) error
	DeleteByUserIDAndType(ctx context.Context, userID string, vType models.VerificationType) error
	DeleteExpired(ctx context.Context) error
	WithTx(tx bun.IDB) VerificationRepository
}

func NewBunVerificationRepository

func NewBunVerificationRepository(db bun.IDB) VerificationRepository

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL