repositories

package
v1.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidSecret indicates that an encryption key is not exactly 32
	// bytes. Config load validates and decodes secrets, so this only surfaces
	// when a caller bypasses config validation.
	ErrInvalidSecret = coresecurity.ErrInvalidSecret
	// ErrInvalidEncryptedToken indicates that an encrypted value is not valid
	// Base64url or is too short to contain a nonce and an authentication tag.
	ErrInvalidEncryptedToken = errors.New("invalid encrypted token")
	// ErrTokenTampered indicates that no configured key could authenticate the
	// encrypted value.
	ErrTokenTampered = errors.New("invalid or tampered token")
)

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)
	GetAllByUserID(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)
	Delete(ctx context.Context, id string) 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) Delete

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

func (*BunAccountRepository) GetAllByUserID

func (r *BunAccountRepository) GetAllByUserID(ctx context.Context, userID string) ([]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

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

func (*BunSessionRepository) DeleteOldestByUserID

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

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) Delete

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

func (*BunUserRepository) GetAll

func (r *BunUserRepository) GetAll(ctx context.Context, cursor *string, limit int) ([]models.User, *string, 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

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

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

func (*BunVerificationRepository) GetByID

func (*BunVerificationRepository) GetByToken

func (*BunVerificationRepository) WithTx

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(currentKey []byte, decryptors [][]byte) (TokenRepository, error)

NewCryptoTokenRepository creates a new token repository

type Transaction

type Transaction any

Transaction represents a database transaction interface

type UserRepository

type UserRepository interface {
	GetAll(ctx context.Context, cursor *string, limit int) ([]models.User, *string, error)
	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
	Delete(ctx context.Context, id string) error
}

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
⌂ 换网址