database

package
v0.0.0-...-14c797c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundFromDB

func IsNotFoundFromDB(err error) bool

func NewDBConnection

func NewDBConnection(config *config.Config) (*sql.DB, error)

func WithTransaction

func WithTransaction(ctx context.Context, db *sql.DB, fn func(q *Queries) error) error

Types

type CreateUserParams

type CreateUserParams struct {
	ID         string
	ScreenName string
	UserName   string
	Bio        string
	IsPrivate  bool
	CreatedAt  time.Time
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (sql.Result, error)

func (*Queries) FindUserByScreenName

func (q *Queries) FindUserByScreenName(ctx context.Context, screenName string) (User, error)

func (*Queries) WithTx

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

type User

type User struct {
	ID         string
	ScreenName string
	UserName   string
	Bio        string
	IsPrivate  bool
	CreatedAt  time.Time
}

func (*User) ToUser

func (u *User) ToUser() *user.User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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