db

package
v0.0.0-...-16335c8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginTx

func BeginTx() (*sql.Tx, error)

BeginTx returns a transaction

func Init

func Init(c *mysql.Config) (err error)

Init database connection

Types

type User

type User struct {
	ID         string
	Name       string
	Password   string
	IsAdmin    bool
	CreatedOn  time.Time
	ModifiedOn mysql.NullTime
}

User represents API user including admin and regular user

func (*User) Create

func (u *User) Create(tx *sql.Tx) error

Create User

func (*User) Delete

func (u *User) Delete(tx *sql.Tx) error

Delete user from DB by user ID

func (*User) Load

func (u *User) Load(tx *sql.Tx, id string) error

Load user data by user ID

func (*User) Scan

func (u *User) Scan(scanner interface {
	Scan(...interface{}) error
}) error

Scan raw database row to user

func (*User) Update

func (u *User) Update(tx *sql.Tx) error

Update user

type UserList

type UserList []User

UserList type

func (*UserList) FromRows

func (l *UserList) FromRows(rows *sql.Rows) error

FromRows scanning rows into user list

func (*UserList) Listup

func (l *UserList) Listup(tx *sql.Tx) error

Listup Users

Jump to

Keyboard shortcuts

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