gopsql

package module
v1.0.42 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: BSD-2-Clause Imports: 14 Imported by: 0

README

gopslq

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTableFound     = errors.New("no table found or no columns in table ")
	ErrTableNameEmpty = errors.New("table name is empty")
)

Functions

func CreateFile added in v1.0.20

func CreateFile(filePath string) (*os.File, string, error)

func CreateMigrationTable added in v1.0.6

func CreateMigrationTable(q Queryer) (e goerr.IError)

func GetTableColumns added in v1.0.20

func GetTableColumns(q Queryer, schema string, table string) (columns *Columns, imports *Imports, e error)

Get table columns from db.

func MakeModel added in v1.0.20

func MakeModel(db Queryer, filePath string, schema string, table string, templatePath string) error

func SnakeToCamel added in v1.0.20

func SnakeToCamel(value string, firstTitle bool) (res string)

func SnakeToCamelWithGOData added in v1.0.31

func SnakeToCamelWithGOData(value string, firstTitle bool) (res string)

Types

type Builder added in v1.0.15

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

func NewBuilder added in v1.0.18

func NewBuilder() *Builder

func (*Builder) Add added in v1.0.15

func (b *Builder) Add(statement string, args ...interface{})

func (*Builder) Order added in v1.0.37

func (b *Builder) Order(statement string)

func (*Builder) Pagination added in v1.0.15

func (b *Builder) Pagination(limit int, offset int)

func (*Builder) RawSQL added in v1.0.31

func (b *Builder) RawSQL() string

func (*Builder) Select added in v1.0.16

func (b *Builder) Select(statement string, args ...interface{})

func (*Builder) Values added in v1.0.15

func (b *Builder) Values() []interface{}

type Column added in v1.0.20

type Column struct {
	IsNullable      bool
	IsArray         bool
	HasUniqueIndex  bool
	IsPrimaryKey    bool
	Default         *string
	Sequence        *string
	Description     *string
	UniqueIndexName *string
	Name            string
	ModelName       string
	DataType        string
	ModelType       string
	Schema          string
	Table           string
	Tags            string
	Import          []string
}

type Columns added in v1.0.20

type Columns []Column

type Config

type Config struct {
	Host           string `json:"host" yaml:"host"`
	Port           int    `json:"port" yaml:"port"`
	UserName       string `json:"userName" yaml:"userName"`
	DBName         string `json:"dbName" yaml:"dbName"`
	Password       string `json:"password" yaml:"password"`
	SslMode        string `json:"sslMode" yaml:"sslMode"`
	Binary         bool   `json:"binary" yaml:"binary"`
	MaxConnections int    `json:"maxConnections" yaml:"maxConnections"`
	ConnectionIdle int    `json:"connectionIdle" yaml:"connectionIdle"`
}

func (*Config) Connect

func (c *Config) Connect() (db *DB, e goerr.IError)

func (*Config) ConnectionURL added in v1.0.31

func (c *Config) ConnectionURL() (url string, e goerr.IError)

type DB

type DB struct {
	Debug bool
	*sql.DB
}

func (*DB) Begin

func (b *DB) Begin() (tx *Tx, e goerr.IError)

func (*DB) Exec

func (b *DB) Exec(query string, args ...interface{}) (res sql.Result, e goerr.IError)

func (*DB) Query

func (b *DB) Query(query string, args ...interface{}) (rows *sql.Rows, e goerr.IError)

func (*DB) QueryRow

func (b *DB) QueryRow(query string, args ...interface{}) (row *sql.Row, e goerr.IError)

type Imports added in v1.0.20

type Imports []string

func (*Imports) Add added in v1.0.20

func (im *Imports) Add(value string)

type Migration added in v1.0.4

type Migration struct {
	Name    string   `json:"-" yaml:"-"`
	UpSQL   []string `json:"upSql" yaml:"upSql"`
	DownSQL []string `json:"downSql" yaml:"downSql"`
}

func (*Migration) Down added in v1.0.4

func (m *Migration) Down(q Queryer) (e goerr.IError)

func (*Migration) Up added in v1.0.4

func (m *Migration) Up(q Queryer) (e goerr.IError)

type Queryer

type Queryer interface {
	Query(query string, args ...interface{}) (*sql.Rows, goerr.IError)
	Exec(query string, args ...interface{}) (sql.Result, goerr.IError)
	QueryRow(query string, args ...interface{}) (*sql.Row, goerr.IError)
}

type Tx

type Tx struct {
	Debug bool
	*sql.Tx
}

func (*Tx) Exec

func (b *Tx) Exec(query string, args ...interface{}) (res sql.Result, e goerr.IError)

func (*Tx) Query

func (b *Tx) Query(query string, args ...interface{}) (rows *sql.Rows, e goerr.IError)

func (*Tx) QueryRow

func (b *Tx) QueryRow(query string, args ...interface{}) (row *sql.Row, e goerr.IError)

Jump to

Keyboard shortcuts

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