Documentation
¶
Index ¶
- Variables
- type PostgresStorage
- func (s *PostgresStorage) Close() error
- func (s *PostgresStorage) Connect() error
- func (s *PostgresStorage) CreateUser(user *core.User) error
- func (s *PostgresStorage) DeleteUser(id string) error
- func (s *PostgresStorage) GetUserByEmail(email string) (*core.User, error)
- func (s *PostgresStorage) GetUserById(id string) (*core.User, error)
- func (s *PostgresStorage) Ping() error
- func (s *PostgresStorage) UpdateUser(user *core.User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrUserAlreadyExists = errors.New("user already exists") )
Functions ¶
This section is empty.
Types ¶
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
PostgresStorage is a PostgreSQL implementation of the Storage interface.
func New ¶
func New(connString string) (*PostgresStorage, error)
New creates a new PostgreSQL storage instance by opening a connection with the given connection string.
func NewFromDB ¶
func NewFromDB(db *sql.DB) *PostgresStorage
NewFromDB creates a PostgresStorage from an existing *sql.DB connection.
func (*PostgresStorage) Close ¶
func (s *PostgresStorage) Close() error
Close closes the database connection.
func (*PostgresStorage) Connect ¶
func (s *PostgresStorage) Connect() error
Connect verifies the database connection is alive.
func (*PostgresStorage) CreateUser ¶
func (s *PostgresStorage) CreateUser(user *core.User) error
CreateUser creates a new user in PostgreSQL.
func (*PostgresStorage) DeleteUser ¶
func (s *PostgresStorage) DeleteUser(id string) error
DeleteUser removes a user from PostgreSQL.
func (*PostgresStorage) GetUserByEmail ¶
func (s *PostgresStorage) GetUserByEmail(email string) (*core.User, error)
GetUserByEmail retrieves a user by email address.
func (*PostgresStorage) GetUserById ¶
func (s *PostgresStorage) GetUserById(id string) (*core.User, error)
GetUserById retrieves a user by ID.
func (*PostgresStorage) Ping ¶
func (s *PostgresStorage) Ping() error
Ping checks if the database is reachable.
func (*PostgresStorage) UpdateUser ¶
func (s *PostgresStorage) UpdateUser(user *core.User) error
UpdateUser updates an existing user in PostgreSQL.
Click to show internal directories.
Click to hide internal directories.