db

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RecordNotFoundError = pgx.ErrNoRows

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        uuid.UUID `json:"id"`
	Owner     string    `json:"owner"`
	Role      Role      `json:"role"`
	CreatedAt time.Time `json:"created_at"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID            uuid.UUID `json:"id"`
	WalletAddress string    `json:"wallet_address"`
	RefreshToken  string    `json:"refresh_token"`
	UserAgent     string    `json:"user_agent"`
	ClientIp      string    `json:"client_ip"`
	ExpiresAt     time.Time `json:"expires_at"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type NullRole

type NullRole struct {
	Role  Role `json:"role"`
	Valid bool `json:"valid"` // Valid is true if Role is not NULL
}

func (*NullRole) Scan

func (ns *NullRole) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullRole) Value

func (ns NullRole) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Querier

type Querier interface {
	CreateAccount(ctx context.Context, owner string) (Account, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	GetAccountByOwner(ctx context.Context, owner string) (Account, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	RevokeAccountSessions(ctx context.Context, walletAddress string) (pgconn.CommandTag, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateAccount

func (q *Queries) CreateAccount(ctx context.Context, owner string) (Account, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) GetAccountByOwner

func (q *Queries) GetAccountByOwner(ctx context.Context, owner string) (Account, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)

func (*Queries) RevokeAccountSessions

func (q *Queries) RevokeAccountSessions(ctx context.Context, walletAddress string) (pgconn.CommandTag, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Role

type Role string
const (
	RoleAdmin Role = "admin"
	RoleGamer Role = "gamer"
)

func (*Role) Scan

func (e *Role) Scan(src interface{}) error

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

type Session

type Session struct {
	ID            uuid.UUID `json:"id"`
	WalletAddress string    `json:"wallet_address"`
	RefreshToken  string    `json:"refresh_token"`
	UserAgent     string    `json:"user_agent"`
	ClientIp      string    `json:"client_ip"`
	IsRevoked     bool      `json:"is_revoked"`
	ExpiresAt     time.Time `json:"expires_at"`
	CreatedAt     time.Time `json:"created_at"`
}

type Store

type Store interface {
	Querier
}

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

Jump to

Keyboard shortcuts

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