db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect()

Connect connects to the database using the mytoken config

func RunWithinTransaction

func RunWithinTransaction(tx *sqlx.Tx, fn func(*sqlx.Tx) error) error

RunWithinTransaction runs the passed function using the passed transaction; if nil is passed as tx a new transaction is created. This is basically a wrapper function, that works with a possible nil-tx

func Transact

func Transact(fn func(*sqlx.Tx) error) error

Transact does a database transaction for the passed function

Types

type BitBool

type BitBool bool

BitBool is an implementation of a bool for the MySQL type BIT(1). This type allows you to avoid wasting an entire byte for MySQL's boolean type TINYINT.

func (*BitBool) Scan

func (b *BitBool) Scan(src interface{}) error

Scan implements the sql.Scanner interface, and turns the bitfield incoming from MySQL into a BitBool

func (BitBool) Value

func (b BitBool) Value() (driver.Value, error)

Value implements the driver.Valuer interface, and turns the BitBool into a bitfield (BIT(1)) for MySQL storage.

type NullString added in v0.2.0

type NullString struct {
	sql.NullString
}

NullString extends the sql.NullString

func NewNullString

func NewNullString(s string) NullString

NewNullString creates a new NullString from the given string

func (NullString) MarshalJSON added in v0.2.0

func (s NullString) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*NullString) UnmarshalJSON added in v0.2.0

func (s *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

Jump to

Keyboard shortcuts

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