db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 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() error

Connect connects to the database using the mytoken config

func ConnectDSN

func ConnectDSN(dsn string) error

ConnectDSN connects to a database using the dsn string

func DB

func DB() *sqlx.DB

DB returns the database connection

func NewNullString

func NewNullString(s string) sql.NullString

NewNullString creates a new sql.NullString from the given string

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.

Jump to

Keyboard shortcuts

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