storage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

type Postgres[T behemoth.User] struct {
	// contains filtered or unexported fields
}

func NewPostgres

func NewPostgres[T behemoth.User](
	db *sql.DB,
	userTable, primaryKey string,
	factory behemoth.SessionFactory,
	findUserFn behemoth.FindUserFn,
) (*Postgres[T], error)

func (*Postgres[T]) DeleteSession

func (pg *Postgres[T]) DeleteSession(sessionID string) error

DeleteSession removes a session by ID.

func (*Postgres[T]) DeleteUser

func (pg *Postgres[T]) DeleteUser(user *models.User) error

func (*Postgres[T]) FindByPK

func (pg *Postgres[T]) FindByPK(val any) (T, error)

func (*Postgres[T]) GetAllUsers

func (pg *Postgres[T]) GetAllUsers() ([]T, error)

func (*Postgres[T]) GetSession

func (pg *Postgres[T]) GetSession(sessionID string) (behemoth.Session, error)

GetSession retrieves a session by ID, returning an error if not found or expired.

func (*Postgres[T]) SaveSession

func (pg *Postgres[T]) SaveSession(session behemoth.Session, expiresAt time.Time) error

SaveSession stores a session in the database with its expiration time.

func (*Postgres[T]) SaveUser

func (pg *Postgres[T]) SaveUser(user *models.User) (*models.User, error)

func (*Postgres[T]) UpdateUser

func (pg *Postgres[T]) UpdateUser(user *models.User) (*models.User, error)

func (*Postgres[T]) UserExists

func (pg *Postgres[T]) UserExists(user *models.User) (bool, error)

func (*Postgres[T]) WithTransaction

func (pg *Postgres[T]) WithTransaction(fn func(tx *sql.Tx) error) error

type SQLite

type SQLite[T behemoth.User] struct {
	// contains filtered or unexported fields
}

func NewSQLite

func NewSQLite[T behemoth.User](
	db *sql.DB,
	userTable, primaryKey string,
	sessionFactory behemoth.SessionFactory,
	findUserFn behemoth.FindUserFn,
) (*SQLite[T], error)

func (*SQLite[T]) DeleteSession

func (sqlt *SQLite[T]) DeleteSession(sessionID string) error

DeleteSession removes a session by ID.

func (*SQLite[T]) DeleteUser

func (sqlt *SQLite[T]) DeleteUser(user *models.User) error

func (*SQLite[T]) FindByPK

func (sqlt *SQLite[T]) FindByPK(val any) (T, error)

func (*SQLite[T]) GetAllUsers

func (sqlt *SQLite[T]) GetAllUsers() ([]T, error)

func (*SQLite[T]) GetSession

func (sqlt *SQLite[T]) GetSession(sessionID string) (behemoth.Session, error)

GetSession retrieves a session by ID, returning an error if not found or expired.

func (*SQLite[T]) SaveSession

func (sqlt *SQLite[T]) SaveSession(session behemoth.Session, expiresAt time.Time) error

SaveSession stores a session in the database with its expiration time.

func (*SQLite[T]) SaveUser

func (sqlt *SQLite[T]) SaveUser(user *models.User) (*models.User, error)

func (*SQLite[T]) UpdateUser

func (sqlt *SQLite[T]) UpdateUser(user *models.User) (*models.User, error)

func (*SQLite[T]) UserExists

func (sqlt *SQLite[T]) UserExists(user *models.User) (bool, error)

func (*SQLite[T]) WithTransaction

func (sqlt *SQLite[T]) WithTransaction(fn func(tx *sql.Tx) error) error

type ScannableRow

type ScannableRow interface {
	Scan(dest ...any) error
}

Jump to

Keyboard shortcuts

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