Documentation ¶
Overview ¶
Package postgres provides a PostgreSQL repository implementation for storing and managing users.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Host string // Host is the address of the PostgreSQL server. Port string // Port is the port number to connect to on the PostgreSQL server. Username string // Username is the username used to authenticate against the PostgreSQL server. Password string // Password is the password used to authenticate against the PostgreSQL server. DBName string // DBName is the name of the PostgreSQL database to connect to. SSLMode string // SSLMode controls whether or with what priority a secure SSL TCP/IP connection will be negotiated with the PostgreSQL server. }
Config stores the configuration information required to connect to a PostgreSQL database.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository provides an implementation of the user repository for a PostgreSQL database.
func NewUserRepository ¶
func NewUserRepository(db *sqlx.DB) (*UserRepository, error)
NewUserRepository creates a new instance of the UserRepository with the provided handle to the PostgreSQL database.
If db is nil, returns an error.
func (UserRepository) FindUserByUserID ¶
func (r UserRepository) FindUserByUserID(ctx context.Context, userID string) (user domain.User, err error)
FindUserByUserID finds a user in the PostgreSQL database by their user ID.
If the user is not found, returns `user.ErrUserNotFound`.
func (UserRepository) FindUserByUsername ¶
func (r UserRepository) FindUserByUsername(ctx context.Context, username string) (user domain.User, err error)
FindUserByUsername finds a user in the PostgreSQL database by their username.
If the user is not found, returns `user.ErrUserNotFound`.