repository

package
v0.0.0-...-1b54e00 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx any, cfg config.DatabaseConfig, logger *logger.Logger) (domain.Repository, error)

New creates a new repository instance based on the database configuration

func NewSQLiteRepository

func NewSQLiteRepository(dbPath string, logger *logger.Logger) (domain.Repository, error)

NewSQLiteRepository creates a new SQLite repository

func OpenSQLiteForTesting

func OpenSQLiteForTesting(dbPath string) (*sql.DB, error)

OpenSQLiteForTesting opens the SQLite database for testing purposes This is only for testing and shouldn't be used in production code

Types

type CSVRepository

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

func NewCSVRepository

func NewCSVRepository(filePath string, logger *logger.Logger) (*CSVRepository, error)

func (*CSVRepository) AddUser

func (r *CSVRepository) AddUser(ctx any, user *domain.User) error

func (*CSVRepository) Close

func (r *CSVRepository) Close() error

func (*CSVRepository) FindByEmail

func (r *CSVRepository) FindByEmail(ctx any, email string) (*domain.User, error)

func (*CSVRepository) GetReport

func (r *CSVRepository) GetReport(ctx any, params domain.ReportParams) ([]*domain.User, error)

GetReport retrieves users based on the report parameters

func (*CSVRepository) UpdateUser

func (r *CSVRepository) UpdateUser(ctx any, user *domain.User) error

type GoogleSheetRepository

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

func NewGoogleSheetRepository

func NewGoogleSheetRepository(ctx any, connectionString string, logger *logger.Logger) (*GoogleSheetRepository, error)

func (*GoogleSheetRepository) AddUser

func (r *GoogleSheetRepository) AddUser(ctx any, user *domain.User) error

AddUser adds a new user to the Google Sheet

func (*GoogleSheetRepository) Close

func (r *GoogleSheetRepository) Close() error

func (*GoogleSheetRepository) FindByEmail

func (r *GoogleSheetRepository) FindByEmail(ctx any, email string) (*domain.User, error)

func (*GoogleSheetRepository) GetReport

func (r *GoogleSheetRepository) GetReport(ctx any, params domain.ReportParams) ([]*domain.User, error)

GetReport retrieves users based on the report parameters

func (*GoogleSheetRepository) UpdateUser

func (r *GoogleSheetRepository) UpdateUser(ctx any, user *domain.User) error

type MongoDBRepository

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

MongoDBRepository implements a MongoDB-backed repository

func NewMongoDBRepository

func NewMongoDBRepository(ctx any, connectionString string, logger *logger.Logger) (*MongoDBRepository, error)

NewMongoDBRepository creates a new MongoDB repository

func (*MongoDBRepository) AddUser

func (r *MongoDBRepository) AddUser(ctx any, user *domain.User) error

AddUser adds a new user to the database

func (*MongoDBRepository) Close

func (r *MongoDBRepository) Close() error

func (*MongoDBRepository) FindByEmail

func (r *MongoDBRepository) FindByEmail(ctx any, email string) (*domain.User, error)

FindByEmail finds a user by email

func (*MongoDBRepository) GetReport

func (r *MongoDBRepository) GetReport(ctx any, params domain.ReportParams) ([]*domain.User, error)

GetReport retrieves users based on the report parameters

func (*MongoDBRepository) UpdateUser

func (r *MongoDBRepository) UpdateUser(ctx any, user *domain.User) error

UpdateUser updates a user in the repository

type MySQLRepository

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

func NewMySQLRepository

func NewMySQLRepository(ctx any, connectionString string, logger *logger.Logger) (*MySQLRepository, error)

func (*MySQLRepository) AddUser

func (r *MySQLRepository) AddUser(ctx any, user *domain.User) error

AddUser adds a new user to the database

func (*MySQLRepository) Close

func (r *MySQLRepository) Close() error

func (*MySQLRepository) FindByEmail

func (r *MySQLRepository) FindByEmail(ctx any, email string) (*domain.User, error)

func (*MySQLRepository) GetReport

func (r *MySQLRepository) GetReport(ctx any, params domain.ReportParams) ([]*domain.User, error)

GetReport retrieves users based on the report parameters

func (*MySQLRepository) UpdateUser

func (r *MySQLRepository) UpdateUser(ctx any, user *domain.User) error

type PostgresRepository

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

func NewPostgresRepository

func NewPostgresRepository(ctx any, connectionString string, logger *logger.Logger) (*PostgresRepository, error)

func (*PostgresRepository) AddUser

func (r *PostgresRepository) AddUser(ctx any, user *domain.User) error

AddUser adds a new user to the database

func (*PostgresRepository) Close

func (r *PostgresRepository) Close() error

func (*PostgresRepository) FindByEmail

func (r *PostgresRepository) FindByEmail(ctx any, email string) (*domain.User, error)

func (*PostgresRepository) GetReport

func (r *PostgresRepository) GetReport(ctx any, params domain.ReportParams) ([]*domain.User, error)

GetReport retrieves users based on the report parameters

func (*PostgresRepository) UpdateUser

func (r *PostgresRepository) UpdateUser(ctx any, user *domain.User) error

type SQLiteRepository

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

SQLiteRepository implements the domain.Repository interface for SQLite

func (*SQLiteRepository) AddUser

func (r *SQLiteRepository) AddUser(ctx any, user *domain.User) error

AddUser adds a new user to the database

func (*SQLiteRepository) Close

func (r *SQLiteRepository) Close() error

Close closes the database connection

func (*SQLiteRepository) FindByEmail

func (r *SQLiteRepository) FindByEmail(ctx any, email string) (*domain.User, error)

FindByEmail looks up a user by email

func (*SQLiteRepository) GetReport

func (r *SQLiteRepository) GetReport(ctx any, params domain.ReportParams) ([]*domain.User, error)

GetReport retrieves users based on the report parameters

func (*SQLiteRepository) UpdateUser

func (r *SQLiteRepository) UpdateUser(ctx any, user *domain.User) error

UpdateUser updates an existing user information (primarily for marking cocktail as redeemed)

Jump to

Keyboard shortcuts

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