generate

package
v0.0.0-...-76e3a26 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBDriver = map[string]DbTransformer{
	"mysql": &MysqlDB{},
}

Functions

func AskForConfirmation

func AskForConfirmation() bool

func ContainsString

func ContainsString(slice []string, element string) bool

func DirExist

func DirExist(path string) bool

func FileHandler

func FileHandler(methods string, tpl *core.StubTemplate)

func FileModel

func FileModel(driver string, conn string, selectedTables string, tpl *core.StubTemplate)

func FileReader

func FileReader(file string) (f *os.File, err error)

func FileRequest

func FileRequest(name string, tpl *core.StubTemplate)

func GetFileName

func GetFileName(tbName string) (filename string)

func StubReplaces

func StubReplaces(content string, tpl *core.StubTemplate) string

func WriteFile

func WriteFile(file *os.File, content string, tpl *core.StubTemplate)

Types

type Column

type Column struct {
	Name string
	Type string
	Tag  *OrmTag
}

func (*Column) String

func (col *Column) String() string

type DbTransformer

type DbTransformer interface {
	GetTableNames(conn *sql.DB) []string
	GetConstraints(conn *sql.DB, table *Table, blackList map[string]bool)
	GetColumns(conn *sql.DB, table *Table, blackList map[string]bool)
	GetGoDataType(sqlType string) string
}

type ForeignKey

type ForeignKey struct {
	Name      string
	RefSchema string
	RefTable  string
	RefColumn string
	Column    *Column
}

type MysqlDB

type MysqlDB struct{}

func (*MysqlDB) GetColumns

func (m *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[string]bool)

func (*MysqlDB) GetConstraints

func (*MysqlDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool)

func (*MysqlDB) GetGoDataType

func (*MysqlDB) GetGoDataType(dataType string) (goType string)

func (*MysqlDB) GetTableNames

func (*MysqlDB) GetTableNames(db *sql.DB) (tables []string)

type OrmTag

type OrmTag struct {
	Auto        bool
	Pk          bool
	Null        bool
	Index       bool
	Unique      bool
	Column      string
	Size        string
	Decimals    string
	Digits      string
	AutoNow     bool
	AutoNowAdd  bool
	Type        string
	Default     string
	RelOne      bool
	ReverseOne  bool
	RelFk       bool
	ReverseMany bool
	RelM2M      bool
}

func (*OrmTag) String

func (tag *OrmTag) String() string

type Table

type Table struct {
	Name          string
	Pk            string
	Uk            []string
	Fk            map[string]*ForeignKey
	Columns       []*Column
	ImportTimePkg bool
}

func GetTableObjects

func GetTableObjects(tableNames []string, db *sql.DB, dbTransformer DbTransformer) (tables []*Table)

func (*Table) MarshalColumn

func (tb *Table) MarshalColumn() string

func (*Table) String

func (tb *Table) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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