db

package module
v0.0.0-...-97104a7 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverMysql      = "mysql"
	DriverMssql      = "mssql"
	DriverSqlite     = "sqlite"
	DriverPostgresql = "postgresql"
)

Variables

View Source
var SqlPool = sync.Pool{
	New: func() interface{} {
		return &Sql{
			SqlComponent: dialect.SqlComponent{
				Fields:     make([]string, 0),
				TableName:  "",
				Args:       make([]interface{}, 0),
				Wheres:     make([]dialect.Where, 0),
				Leftjoins:  make([]dialect.Join, 0),
				UpdateRaws: make([]dialect.RawUpdate, 0),
				WhereRaws:  "",
			},
			diver:   nil,
			dialect: nil,
		}
	},
}

Functions

func Exec

func Exec(query string, args ...interface{}) sql.Result

func Query

func Query(query string, args ...interface{}) ([]map[string]interface{}, *sql.Rows)

func RecycleSql

func RecycleSql(sql *Sql)

Types

type Connection

type Connection interface {
	Query(query string, args ...interface{}) ([]map[string]interface{}, *sql.Rows)
	Exec(query string, args ...interface{}) sql.Result
	QueryWithConnection(conn, query string, args ...interface{}) ([]map[string]interface{}, *sql.Rows)
	ExecWithConnection(conn, query string, args ...interface{}) sql.Result
	InitDB(cfg map[string]config.Database)
	GetName() string
}

func GetConnection

func GetConnection() Connection

func GetConnectionByDriver

func GetConnectionByDriver(driver string) Connection

type H

type H map[string]interface{}

type Join

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

type RawUpdate

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

type Sql

type Sql struct {
	dialect.SqlComponent
	// contains filtered or unexported fields
}

func Table

func Table(table string) *Sql

func WithDriver

func WithDriver(driver string) *Sql

func WithDriverAndConnection

func WithDriverAndConnection(conn, driver string) *Sql

func (*Sql) All

func (sql *Sql) All() ([]map[string]interface{}, error)

func (*Sql) Count

func (sql *Sql) Count() (int64, error)

func (*Sql) Delete

func (sql *Sql) Delete() error

func (*Sql) Exec

func (sql *Sql) Exec() (int64, error)

func (*Sql) Find

func (sql *Sql) Find(arg interface{}) (map[string]interface{}, error)

func (*Sql) First

func (sql *Sql) First() (map[string]interface{}, error)

func (*Sql) Insert

func (sql *Sql) Insert(values dialect.H) (int64, error)

func (*Sql) LeftJoin

func (sql *Sql) LeftJoin(table string, fieldA string, operation string, fieldB string) *Sql

func (*Sql) OrderBy

func (sql *Sql) OrderBy(fields ...string) *Sql

func (*Sql) Select

func (sql *Sql) Select(fields ...string) *Sql

func (*Sql) ShowColumns

func (sql *Sql) ShowColumns() ([]map[string]interface{}, error)

func (*Sql) ShowTables

func (sql *Sql) ShowTables() ([]map[string]interface{}, error)

func (*Sql) Skip

func (sql *Sql) Skip(offset int) *Sql

func (*Sql) Table

func (sql *Sql) Table(table string) *Sql

func (*Sql) Take

func (sql *Sql) Take(take int) *Sql

func (*Sql) Update

func (sql *Sql) Update(values dialect.H) (int64, error)

func (*Sql) UpdateRaw

func (sql *Sql) UpdateRaw(raw string, args ...interface{}) *Sql

func (*Sql) Where

func (sql *Sql) Where(field string, operation string, arg interface{}) *Sql

func (*Sql) WhereIn

func (sql *Sql) WhereIn(field string, arg []interface{}) *Sql

func (*Sql) WhereNotIn

func (sql *Sql) WhereNotIn(field string, arg []interface{}) *Sql

func (*Sql) WhereRaw

func (sql *Sql) WhereRaw(raw string, args ...interface{}) *Sql

func (*Sql) WithConnection

func (sql *Sql) WithConnection(conn string) *Sql

type Where

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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