schema

package
v0.3.1-0...-35701da Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTypeInt64   = "int64"
	CTypeInt     = "int"
	CTypeUInt    = "uint"
	CTypeString  = "string"
	CTypeFloat64 = "float64"
	CTypeTime    = "time.Time"
	CTypeInt8    = "int8"
	CTypeUInt64  = "uint64"
	CTypeByte    = "byte"
	CUnsigned    = "unsigned"
)
View Source
const DefaultSchemaOutputRootPath = "dao/mysql/schema"

Variables

View Source
var (
	TypeWrappers = []typeWrapper{i64TypeWrapper, byteTypeWrapper, intTypeWrapper, float64TypeWrapper, stringTypeWrapper, timeTypeWrapper}
)

Functions

func AddImportContent

func AddImportContent(packageName string) io.Reader

func Convert2PackageName

func Convert2PackageName(tableName string) string

转换转换下划线,用于包命名

func ConvertUnderScoreToCamel

func ConvertUnderScoreToCamel(name string) string

转换下划线字符串为驼峰格式,用于go 结构体命名

func GenSchemaStruct

func GenSchemaStruct(w io.Writer, schemaArgs *SchemaArgs) (string, error)

schema转换struct的公用调用方法,用于schema命令的直接调用

func GetDBInstance

func GetDBInstance(conf *DBConfig) (*sql.DB, error)

func OutputFile

func OutputFile(rootPath, tableName string) (io.Writer, error)

输出

Types

type Column

type Column struct {
	Name    string `json:"COLUMN_NAME"`
	Type    string `json:"COLUMN_TYPE"`
	Comment string `json:"COLUMN_COMMENT"`
}

Column stands for a column of a table

func (*Column) GetName

func (c *Column) GetName() string

GetName returns the Cammel Name of the struct

func (*Column) GetType

func (c *Column) GetType() (string, error)

GetType returns which built in type the column should be in generated go code

type ColumnSlice

type ColumnSlice []Column

func GetSchemaField

func GetSchemaField(schemaArgs *SchemaArgs) (ColumnSlice, error)

从数据库表导出字段的方法,用于module命令的调用

type DBConfig

type DBConfig struct {
	Host     string `json:"host"`
	User     string `json:"user"`
	Password string `json:"password"`
	Port     int    `json:"port"`
	DBName   string `json:"database"`
}

DBConfig holds the basic configuration of database

type SchemaArgs

type SchemaArgs struct {
	Database string
	Table    string
	User     string
	Password string
	Host     string
	Port     int
}

Jump to

Keyboard shortcuts

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