model

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupByColumn

func GroupByColumn(indexList []*Index) map[string][]*Index

Types

type Column

type Column struct {
	TableName     string   `gorm:"column:TABLE_NAME"`
	ColumnName    string   `gorm:"column:COLUMN_NAME"`
	ColumnComment string   `gorm:"column:COLUMN_COMMENT"`
	DataType      string   `gorm:"column:DATA_TYPE"`
	ColumnKey     string   `gorm:"column:COLUMN_KEY"`
	ColumnType    string   `gorm:"column:COLUMN_TYPE"`
	ColumnDefault string   `gorm:"column:COLUMN_DEFAULT"`
	Extra         string   `gorm:"column:EXTRA"`
	IsNullable    string   `gorm:"column:IS_NULLABLE"`
	Indexes       []*Index `gorm:"-"`
	// contains filtered or unexported fields
}

Column table column's info

func (*Column) AutoIncrement

func (c *Column) AutoIncrement() bool

func (*Column) GetDataType

func (c *Column) GetDataType() (memberType string)

func (*Column) IsPrimaryKey

func (c *Column) IsPrimaryKey() bool

func (*Column) SetDataTypeMap

func (c *Column) SetDataTypeMap(m map[string]func(detailType string) (dataType string))

func (*Column) ToMember

func (c *Column) ToMember(nullable bool) *Member

type CreateMemberOpt

type CreateMemberOpt ModifyMemberOpt

func (CreateMemberOpt) Self

func (o CreateMemberOpt) Self() func(*Member) *Member

type DBConf

type DBConf struct {
	ModelPkg  string
	TableName string
	ModelName string

	SchemaNameOpts []SchemaNameOpt
	MemberOpts     []MemberOpt

	DataTypeMap map[string]func(detailType string) (dataType string)

	GenerateModelConfig
}

func (*DBConf) GetSchemaName

func (cf *DBConf) GetSchemaName(db *gorm.DB) string

func (*DBConf) SortOpt

func (cf *DBConf) SortOpt() (modifyOpts []MemberOpt, filterOpts []MemberOpt, createOpts []MemberOpt)

type FilterMemberOpt

type FilterMemberOpt ModifyMemberOpt

func (FilterMemberOpt) Self

func (o FilterMemberOpt) Self() func(*Member) *Member

type GenerateModelConfig

type GenerateModelConfig struct {
	FieldNullable     bool // generate pointer when field is nullable
	FieldWithIndexTag bool // generate with gorm index tag
	FieldWithTypeTag  bool // generate with gorm column type tagl
}

type Index

type Index struct {
	TableName  string `gorm:"column:TABLE_NAME"`
	ColumnName string `gorm:"column:COLUMN_NAME"`
	IndexName  string `gorm:"column:INDEX_NAME"`
	SeqInIndex int32  `gorm:"column:SEQ_IN_INDEX"`
	NonUnique  int32  `gorm:"column:NON_UNIQUE"`
}

Index table index info

func (*Index) IsPrimaryKey

func (c *Index) IsPrimaryKey() bool

func (*Index) IsUnique

func (c *Index) IsUnique() bool

not primary key but unique key

type Member

type Member struct {
	Name             string
	Type             string
	ColumnName       string
	ColumnComment    string
	MultilineComment bool
	JSONTag          string
	GORMTag          string
	NewTag           string
	OverwriteTag     string

	Relation *field.Relation
}

Member user input structures

func (*Member) EscapeKeyword

func (m *Member) EscapeKeyword() *Member

func (*Member) GenType

func (m *Member) GenType() string

func (*Member) IsRelation

func (m *Member) IsRelation() bool

type MemberOpt

type MemberOpt interface{ Self() func(*Member) *Member }

type ModifyMemberOpt

type ModifyMemberOpt func(*Member) *Member

func (ModifyMemberOpt) Self

func (o ModifyMemberOpt) Self() func(*Member) *Member

type SQLBuffer

type SQLBuffer struct{ bytes.Buffer }

func (*SQLBuffer) Dump

func (s *SQLBuffer) Dump() string

func (*SQLBuffer) WriteSql

func (s *SQLBuffer) WriteSql(b byte)

type SchemaNameOpt

type SchemaNameOpt func(*gorm.DB) string

type SourceCode

type SourceCode int
const (
	Struct SourceCode = iota
	TableName
)

type Status

type Status int
const (
	UNKNOWN Status = iota
	SQL
	DATA
	VARIABLE
	WHERE
	IF
	SET
	ELSE
	ELSEIF
	END
	BOOL
	INT
	STRING
	TIME
	OTHER
	EXPRESSION
	LOGICAL
	NIL
)

Jump to

Keyboard shortcuts

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