Documentation
¶
Index ¶
- Variables
- type SQLStorage
- func (s *SQLStorage) AutoMigrate() error
- func (s *SQLStorage) Close() error
- func (s *SQLStorage) CreateUser(user *core.User) error
- func (s *SQLStorage) DeleteUser(id string) error
- func (s *SQLStorage) GetUserByEmail(email string) (*core.User, error)
- func (s *SQLStorage) GetUserById(id string) (*core.User, error)
- func (s *SQLStorage) 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 SQLStorage ¶
type SQLStorage struct {
// contains filtered or unexported fields
}
SQLStorage is a generic SQL implementation of the Storage interface. It works with any database/sql compatible driver (postgres, mysql, sqlite).
func New ¶
func New(db *sql.DB, tableName string) *SQLStorage
New creates a new SQL storage instance with the given database connection and table name.
func (*SQLStorage) AutoMigrate ¶
func (s *SQLStorage) AutoMigrate() error
AutoMigrate creates the users table if it does not exist.
func (*SQLStorage) Close ¶
func (s *SQLStorage) Close() error
Close closes the underlying database connection.
func (*SQLStorage) CreateUser ¶
func (s *SQLStorage) CreateUser(user *core.User) error
CreateUser creates a new user in the database.
func (*SQLStorage) DeleteUser ¶
func (s *SQLStorage) DeleteUser(id string) error
DeleteUser removes a user from the database.
func (*SQLStorage) GetUserByEmail ¶
func (s *SQLStorage) GetUserByEmail(email string) (*core.User, error)
GetUserByEmail retrieves a user by email address.
func (*SQLStorage) GetUserById ¶
func (s *SQLStorage) GetUserById(id string) (*core.User, error)
GetUserById retrieves a user by ID.
func (*SQLStorage) UpdateUser ¶
func (s *SQLStorage) UpdateUser(user *core.User) error
UpdateUser updates an existing user.
Click to show internal directories.
Click to hide internal directories.