dbx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database represents a connection to a SQL database

func New

func New() (*Database, error)

New creates a new Database instance

func NewWithLogger

func NewWithLogger(logger *log.Logger) (*Database, error)

NewWithLogger creates a new Database instance with logging

func (Database) Begin

func (db Database) Begin() (*Trx, error)

Begin returns a new SQL transaction

func (Database) Close

func (db Database) Close() error

Close connection to database

func (Database) Migrate

func (db Database) Migrate()

Migrate the database to latest verion

func (Database) Seed

func (db Database) Seed()

Seed clean and insert new seed data for testing

type NullInt

type NullInt struct {
	sql.NullInt64
}

NullInt representa a nullable integer

func (NullInt) MarshalJSON

func (r NullInt) MarshalJSON() ([]byte, error)

MarshalJSON interface redefinition

type NullString

type NullString struct {
	sql.NullString
}

NullString representa a nullable string

func (NullString) MarshalJSON

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

MarshalJSON interface redefinition

type NullTime

type NullTime struct {
	pq.NullTime
}

NullTime representa a nullable time.Time

func (NullTime) MarshalJSON

func (r NullTime) MarshalJSON() ([]byte, error)

MarshalJSON interface redefinition

type Trx

type Trx struct {
	// contains filtered or unexported fields
}

Trx represents a Database transaction

func (Trx) Commit

func (trx Trx) Commit() error

Commit current transaction

func (Trx) Count

func (trx Trx) Count(command string, args ...interface{}) (int, error)

Count returns number of rows

func (Trx) Execute

func (trx Trx) Execute(command string, args ...interface{}) error

Execute given SQL command

func (Trx) Exists

func (trx Trx) Exists(command string, args ...interface{}) (bool, error)

Exists returns true if at least one record is found

func (Trx) Get

func (trx Trx) Get(data interface{}, command string, args ...interface{}) error

Get first row and bind to given data

func (Trx) Query

func (trx Trx) Query(command string, args ...interface{}) (*sql.Rows, error)

Query the database with given SQL command

func (Trx) QueryIntArray

func (trx Trx) QueryIntArray(command string, args ...interface{}) ([]int, error)

QueryIntArray executes given SQL command and return first column as int

func (Trx) QueryRow

func (trx Trx) QueryRow(command string, args ...interface{}) *sql.Row

QueryRow the database with given SQL command and returns only one row

func (Trx) Rollback

func (trx Trx) Rollback() error

Rollback current transaction

func (Trx) Select

func (trx Trx) Select(data interface{}, command string, args ...interface{}) error

Select all matched rows bind to given data

Jump to

Keyboard shortcuts

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