model

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cfg

type Cfg struct {
	Models []MultiModelCfg `json:"models" yaml:"models"`
}

type Column

type Column struct {
	*DbColumn
	Index *DbIndex
}

Column defines column in table

type ColumnData

type ColumnData struct {
	Db      string
	Table   string
	Columns []*Column
}

ColumnData describes the columns of table

func (*ColumnData) Convert

func (c *ColumnData) Convert() (*Table, error)

Convert converts column data into Table

type DBTable

type DBTable struct {
	TABLE_NAME    string
	TABLE_COMMENT string
}

type DbColumn

type DbColumn struct {
	Name            string      `db:"COLUMN_NAME"`
	DataType        string      `db:"DATA_TYPE"`
	Extra           string      `db:"EXTRA"`
	Comment         string      `db:"COLUMN_COMMENT"`
	ColumnDefault   interface{} `db:"COLUMN_DEFAULT"`
	IsNullAble      string      `db:"IS_NULLABLE"`
	OrdinalPosition int         `db:"ORDINAL_POSITION"`
}

DbColumn defines column info of columns

type DbIndex

type DbIndex struct {
	IndexName  string `db:"INDEX_NAME"`
	NonUnique  int    `db:"NON_UNIQUE"`
	SeqInIndex int    `db:"SEQ_IN_INDEX"`
}

DbIndex defines index of columns in information_schema.statistic

type Index

type Index struct {
	IndexType IndexType
	Columns   []*Column
}

Index describes a column index

type IndexType

type IndexType string

IndexType describes an alias of string

type InformationSchemaModel

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

InformationSchemaModel defines information schema model

func NewInformationSchemaModel

func NewInformationSchemaModel(conn sqlx.SqlConn) *InformationSchemaModel

NewInformationSchemaModel creates an instance for InformationSchemaModel

func (*InformationSchemaModel) FindColumns

func (m *InformationSchemaModel) FindColumns(db, table string) (*ColumnData, error)

FindColumns return columns in specified database and table

func (*InformationSchemaModel) FindIndex

func (m *InformationSchemaModel) FindIndex(db, table, column string) ([]*DbIndex, error)

FindIndex finds index with given db, table and column.

func (*InformationSchemaModel) GetAllTables

func (m *InformationSchemaModel) GetAllTables(database string) ([]*DBTable, error)

GetAllTables selects all tables from TABLE_SCHEMA

type MultiModelCfg added in v1.0.3

type MultiModelCfg struct {
	Table        string              `json:"table" yaml:"table"`
	Group        string              `json:"group" yaml:"group"`
	Package      string              `json:"package" yaml:"package"`
	AliasPackage string              `json:"aliasPackage" yaml:"aliasPackage"`
	Fields       []string            `json:"fields" yaml:"fields"`
	Excludes     []string            `json:"excludes" yaml:"excludes"`
	Joins        []MultiModelJoinCfg `json:"joins" yaml:"joins"`
}

func NewMultiModelCfg added in v1.0.3

func NewMultiModelCfg(filename string) ([]MultiModelCfg, error)

type MultiModelJoinCfg added in v1.0.3

type MultiModelJoinCfg struct {
	Table        string   `json:"table" yaml:"table"`
	Group        string   `json:"group" yaml:"group"`
	Alias        string   `json:"alias" yaml:"alias"`
	JoinType     string   `json:"joinType" yaml:"joinType"`
	Package      string   `json:"package" yaml:"package"`
	AliasPackage string   `json:"aliasPackage" yaml:"aliasPackage"`
	ForeignKey   string   `json:"foreignKey" yaml:"foreignKey"`
	References   string   `json:"references" yaml:"references"`
	Fields       []string `json:"fields" yaml:"fields"`
	Excludes     []string `json:"excludes" yaml:"excludes"`
}

type Table

type Table struct {
	Db      string
	Table   string
	Comment string
	Columns []*Column
	// Primary key not included
	UniqueIndex map[string][]*Column
	PrimaryKey  *Column
	NormalIndex map[string][]*Column

	MultiModelCfg MultiModelCfg
}

Table describes mysql table which contains database name, table name, columns, keys

Jump to

Keyboard shortcuts

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