sql

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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.

Jump to

Keyboard shortcuts

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