Documentation
¶
Index ¶
- Variables
- type MySQLStorage
- func (s *MySQLStorage) Close() error
- func (s *MySQLStorage) Connect() error
- func (s *MySQLStorage) CreateUser(user *core.User) error
- func (s *MySQLStorage) DeleteUser(id string) error
- func (s *MySQLStorage) GetUserByEmail(email string) (*core.User, error)
- func (s *MySQLStorage) GetUserById(id string) (*core.User, error)
- func (s *MySQLStorage) Ping() error
- func (s *MySQLStorage) 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 MySQLStorage ¶
type MySQLStorage struct {
// contains filtered or unexported fields
}
MySQLStorage is a MySQL implementation of the Storage interface.
func New ¶
func New(dsn string) (*MySQLStorage, error)
New creates a new MySQL storage instance by opening a connection with the given DSN.
func NewFromDB ¶
func NewFromDB(db *sql.DB) *MySQLStorage
NewFromDB creates a MySQLStorage from an existing *sql.DB connection.
func (*MySQLStorage) Close ¶
func (s *MySQLStorage) Close() error
Close closes the database connection.
func (*MySQLStorage) Connect ¶
func (s *MySQLStorage) Connect() error
Connect verifies the database connection is alive.
func (*MySQLStorage) CreateUser ¶
func (s *MySQLStorage) CreateUser(user *core.User) error
CreateUser creates a new user in MySQL.
func (*MySQLStorage) DeleteUser ¶
func (s *MySQLStorage) DeleteUser(id string) error
DeleteUser removes a user from MySQL.
func (*MySQLStorage) GetUserByEmail ¶
func (s *MySQLStorage) GetUserByEmail(email string) (*core.User, error)
GetUserByEmail retrieves a user by email address.
func (*MySQLStorage) GetUserById ¶
func (s *MySQLStorage) GetUserById(id string) (*core.User, error)
GetUserById retrieves a user by ID.
func (*MySQLStorage) Ping ¶
func (s *MySQLStorage) Ping() error
Ping checks if the database is reachable.
func (*MySQLStorage) UpdateUser ¶
func (s *MySQLStorage) UpdateUser(user *core.User) error
UpdateUser updates an existing user in MySQL.
Click to show internal directories.
Click to hide internal directories.