db

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 9 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 ConnectConfig added in v0.3.0

func ConnectConfig(conf config.DBConf)

ConnectConfig connects to the database using the passed config

func NewNullTime added in v0.4.0

func NewNullTime(t time.Time) sql.NullTime

NewNullTime creates a new sql.NullTime from the given time.Time

func ParseError added in v0.4.0

func ParseError(err error) (bool, error)

ParseError parses the passed error for a sql.ErrNoRows

func RunWithinTransaction

func RunWithinTransaction(rlog log.Ext1FieldLogger, 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(rlog log.Ext1FieldLogger, 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