db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	UserID uint64
	ID     int64
	Image  string
	Name   string
	Date   time.Time
	Type   string
}

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 NewDB

func NewDB(connstr string) (*Queries, error)

NewDB initialises the connetion with the db

func Prepare

func Prepare(ctx context.Context, db DBTX) (*Queries, error)

func (*Queries) AddDropToken

func (q *Queries) AddDropToken(ctx context.Context, userID corde.Snowflake) error

func (*Queries) Chars

func (q *Queries) Chars(ctx context.Context, userID corde.Snowflake) ([]discord.Character, error)

Chars returns the user's characters

func (*Queries) CharsIDs

func (q *Queries) CharsIDs(ctx context.Context, userID corde.Snowflake) ([]int64, error)

CharsIDs returns the user's character's ID

func (*Queries) CharsStartingWith

func (q *Queries) CharsStartingWith(ctx context.Context, userID corde.Snowflake, s string) ([]discord.Character, error)

CharsStartingWith returns characters starting with the given string

func (*Queries) Close

func (q *Queries) Close() error

func (*Queries) ConsumeDropTokens

func (q *Queries) ConsumeDropTokens(ctx context.Context, userID corde.Snowflake, count int32) (discord.User, error)

func (*Queries) DeleteChar

func (q *Queries) DeleteChar(ctx context.Context, userID corde.Snowflake, charID int64) (discord.Character, error)

func (*Queries) GiveUserChar

func (q *Queries) GiveUserChar(ctx context.Context, dst corde.Snowflake, src corde.Snowflake, charID int64) error

func (*Queries) Profile

func (q *Queries) Profile(ctx context.Context, userID corde.Snowflake) (discord.Profile, error)

Profile returns the user's profile

func (*Queries) PutChar

func (q *Queries) PutChar(ctx context.Context, userID corde.Snowflake, c discord.Character) error

PutChar a char in the database

func (*Queries) SetChar

func (q *Queries) SetChar(ctx context.Context, arg SetCharParams) (Character, error)

func (*Queries) SetUserAnilistURL

func (q *Queries) SetUserAnilistURL(ctx context.Context, userID corde.Snowflake, url string) error

func (*Queries) SetUserDate

func (q *Queries) SetUserDate(ctx context.Context, userID corde.Snowflake, d time.Time) error

SetUserDate sets the user's date

func (*Queries) SetUserFavorite

func (q *Queries) SetUserFavorite(ctx context.Context, userID corde.Snowflake, c int64) error

SetUserFavorite sets the user's favorite

func (*Queries) SetUserQuote

func (q *Queries) SetUserQuote(ctx context.Context, userID corde.Snowflake, quote string) error

SetUserQuote sets the user's quote

func (*Queries) SetUserToken

func (q *Queries) SetUserToken(ctx context.Context, userID corde.Snowflake, token string) error

SetUserToken sets the user's token

func (*Queries) Tx

func (q *Queries) Tx(fn func(s discord.Store) error) error

Tx executes a function in a transaction.

func (*Queries) User

func (q *Queries) User(ctx context.Context, userID corde.Snowflake) (discord.User, error)

User returns a user

func (*Queries) VerifyChar

func (q *Queries) VerifyChar(ctx context.Context, userID corde.Snowflake, charID int64) (discord.Character, error)

func (*Queries) WithTx

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

type SetCharParams

type SetCharParams struct {
	Image string
	Name  string
	ID    int64
}

type User

type User struct {
	ID         int32
	UserID     uint64
	Quote      string
	Date       time.Time
	Favorite   sql.NullInt64
	Tokens     int32
	AnilistUrl string
}

Jump to

Keyboard shortcuts

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