Help us shape the future of Go! Take the 2026 Go Developer Survey

db

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntConvert

func IntConvert[From, To ~int | ~int8 | ~int16 | ~int32 | ~int64 |
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
	~float32 | ~float64](src From) To

func IntPtrConvert

func IntPtrConvert[From, To ~int | ~int32 | ~int64 | ~float32 | ~float64](src *From) *To

example: IntPtrConvert[int64, int32](dbRow.Age)

func NullBoolToPtr

func NullBoolToPtr(n sql.NullBool) *bool

func NullBytesToPtr

func NullBytesToPtr(b []byte) *[]byte

--- Bytes Converters ---

func NullFloat64ToPtr

func NullFloat64ToPtr(n sql.NullFloat64) *float64

func NullInt32ToPtr

func NullInt32ToPtr(n sql.NullInt32) *int32

--- Nullable SQL Type Converters ---

func NullInt64ToPtr

func NullInt64ToPtr(n sql.NullInt64) *int64

func NullStringToPtr

func NullStringToPtr(n sql.NullString) *string

func NullTimeToProto

func NullTimeToProto(n sql.NullTime) *timestamppb.Timestamp

--- Time Converters ---

func OptionalWithFallback

func OptionalWithFallback[T any](val *T, fallback T) T

OptionalWithFallback chooses fallback if optional value is nil

func ProtoToNullTime

func ProtoToNullTime(t *timestamppb.Timestamp) sql.NullTime

func ProtoToTime

func ProtoToTime(t *timestamppb.Timestamp) time.Time

A nil pointer returns a zero time.Time{}

func PtrBytesToNullString

func PtrBytesToNullString(p *[]byte) sql.NullString

PtrBytesToNullString converts *[]byte to sql.NullString for MySQL compatibility

func PtrToNullBool

func PtrToNullBool(p *bool) sql.NullBool

func PtrToNullBytes

func PtrToNullBytes(b *[]byte) []byte

func PtrToNullFloat64

func PtrToNullFloat64(p *float64) sql.NullFloat64

func PtrToNullInt32

func PtrToNullInt32(p *int32) sql.NullInt32

func PtrToNullInt64

func PtrToNullInt64(p *int64) sql.NullInt64

func PtrToNullString

func PtrToNullString(p *string) sql.NullString

func SQLiteBoolPtrToInt64Ptr

func SQLiteBoolPtrToInt64Ptr(b *bool) *int64

SQLiteBoolPtrToInt64Ptr converts *bool to *int64 for nullable columns via sqlc.narg

func SQLiteBoolToInt

func SQLiteBoolToInt(b bool) int64

func SQLiteInt64PtrToBoolPtr

func SQLiteInt64PtrToBoolPtr(i *int64) *bool

SQLiteInt64PtrToBoolPtr is the inverse of SQLiteBoolPtrToInt64Ptr.

func SQLiteIntToBool

func SQLiteIntToBool(i int64) bool

--- SQLite bool converters ---

func TimeToProto

func TimeToProto(t time.Time) *timestamppb.Timestamp

TimeToProto converts time.Time to timestamppb.Timestamp pointer

Types

type Audit

type Audit struct {
	ID        int32     `json:"ID"`
	Action    string    `json:"action"`
	MatchID   int32     `json:"match_id"`
	Detail    string    `json:"detail"`
	CreatedAt time.Time `json:"created_at"`
}

func AuditFromSQL

func AuditFromSQL(db *internal.Audit) *Audit

func (*Audit) AuditToSQL

func (m *Audit) AuditToSQL() *internal.Audit

type CreateAuditParams

type CreateAuditParams struct {
	Action    string     `json:"action"`
	MatchID   int32      `json:"match_id"`
	Detail    string     `json:"detail"`
	CreatedAt *time.Time `json:"created_at"`
}

type CreateMatchParams

type CreateMatchParams struct {
	White    string     `json:"white"`
	Black    string     `json:"black"`
	Result   string     `json:"result"`
	Opening  *string    `json:"opening"`
	Moves    int32      `json:"moves"`
	PlayedAt *time.Time `json:"played_at"`
}

type CreatePlayerParams added in v0.0.3

type CreatePlayerParams struct {
	Name   string  `json:"name"`
	Rating int32   `json:"rating"`
	Title  *string `json:"title"`
}

type DBTX

type DBTX = internal.DBTX

type Match

type Match struct {
	ID        int32     `json:"ID"`
	White     string    `json:"white"`
	Black     string    `json:"black"`
	Result    string    `json:"result"`
	Opening   *string   `json:"opening"`
	Moves     int32     `json:"moves"`
	PlayedAt  time.Time `json:"played_at"`
	CreatedAt time.Time `json:"created_at"`
}

func MatchFromSQL

func MatchFromSQL(db *internal.Match) *Match

func (*Match) MatchToSQL

func (m *Match) MatchToSQL() *internal.Match

func (*Match) ToProto

func (m *Match) ToProto() *pb.Match

ToProto converts Match to proto format

type Player added in v0.0.3

type Player struct {
	ID       int32     `json:"ID"`
	Name     string    `json:"name"`
	Rating   int32     `json:"rating"`
	Title    *string   `json:"title"`
	JoinedAt time.Time `json:"joined_at"`
}

func PlayerFromSQL added in v0.0.3

func PlayerFromSQL(db *internal.Player) *Player

func (*Player) PlayerToSQL added in v0.0.3

func (m *Player) PlayerToSQL() *internal.Player

func (*Player) ToProto added in v0.0.3

func (m *Player) ToProto() *pb.Player

ToProto converts Player to proto format

type Queries

type Queries internal.Queries

func New

func New(db DBTX) *Queries

func (*Queries) CreateAudit

func (q *Queries) CreateAudit(ctx context.Context, arg CreateAuditParams) (int32, error)

func (*Queries) CreateMatch

func (q *Queries) CreateMatch(ctx context.Context, arg CreateMatchParams) (int32, error)

func (*Queries) CreatePlayer added in v0.0.3

func (q *Queries) CreatePlayer(ctx context.Context, arg CreatePlayerParams) (int32, error)

func (*Queries) DeleteAllMatch added in v0.0.3

func (q *Queries) DeleteAllMatch(ctx context.Context) error

func (*Queries) DeleteMatch

func (q *Queries) DeleteMatch(ctx context.Context, id int32) error

func (*Queries) GetMatchByID

func (q *Queries) GetMatchByID(ctx context.Context, id int32) (*Match, error)

func (*Queries) GetPlayerByID added in v0.0.3

func (q *Queries) GetPlayerByID(ctx context.Context, id int32) (*Player, error)

func (*Queries) ListAllAudit

func (q *Queries) ListAllAudit(ctx context.Context) ([]*Audit, error)

func (*Queries) ListAllMatch

func (q *Queries) ListAllMatch(ctx context.Context) ([]*Match, error)

func (*Queries) ListAllPlayer added in v0.0.3

func (q *Queries) ListAllPlayer(ctx context.Context) ([]*Player, error)

func (*Queries) WithTx

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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