gopsql

package module
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: BSD-2-Clause Imports: 13 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")
)
View Source
var (
	ErrQuerierIsNil = errors.New("Queryer is nil ")
	ErrNoData       = errors.New("No data")
)

Functions

func CreateFile

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

func CreateMigrationTable

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

func GetTableColumns

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

Get table columns from db.

func MakeModel

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

func SnakeToCamel

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

func SnakeToCamelWithGOData

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

Types

type Builder

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

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Add

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

func (*Builder) Order

func (b *Builder) Order(statement string)

func (*Builder) Pagination

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

func (*Builder) RawSQL

func (b *Builder) RawSQL() string

func (*Builder) Select

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

func (*Builder) Values

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

type Column

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

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

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

type Imports []string

func (*Imports) Add

func (im *Imports) Add(value string)

type Migration

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

func (*Migration) Down

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

func (*Migration) Up

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