schema

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Tag string

	Field objs.Object
	Type  *types.SQLType

	// 忽略该字段 -
	Ignore bool
	// 主键 pk
	IsPrimaryKey bool
	// 自增类型 autoincr
	IsAutoIncrement bool
	// 是否可为空 null | not-null
	Nullable bool
	// 是否索引 index | index(索引名称)
	IsIndex bool
	// IndexNames []string
	// 是否唯一索引 unique | unique(索引名称)
	IsUnique bool
	// UniqueNames []string
	// 默认值 default(值)
	Default string

	// IsJSON 是否 json
	IsJSON bool

	Length  int
	Length2 int

	Indexes map[string]int

	TimeZone *time.Location
	// contains filtered or unexported fields
}

func (*Column) FieldName

func (c *Column) FieldName() string

type Index

type Index struct {
	Regular bool
	Name    string
	Type    int
	Cols    []string
}

Index represents a database index

func NewIndex

func NewIndex(name string, indexType int) *Index

NewIndex new an index object

func (*Index) AddColumn

func (index *Index) AddColumn(cols ...string)

AddColumn add columns which will be composite index

func (*Index) Equal

func (index *Index) Equal(dst *Index) bool

func (*Index) XName

func (index *Index) XName(tableName string) string

type Table

type Table struct {
	// dialect     dialects.Dialect
	// Model       interface{}
	Type        reflect.Type
	Name        string
	Columns     []*Column
	ColumnNames []string

	Indexes       map[string]*Index
	PrimaryKeys   []string
	AutoIncrement string
	// contains filtered or unexported fields
}

func NewEmptyTable

func NewEmptyTable() *Table

func NewTable

func NewTable(modelType reflect.Type, tableName string) *Table

func (*Table) AddColumn

func (t *Table) AddColumn(col *Column)

func (*Table) AddIndex

func (t *Table) AddIndex(name string, typ int, col *Column)

func (*Table) GetColumn

func (t *Table) GetColumn(name string) *Column

func (*Table) GetPKColumns

func (table *Table) GetPKColumns() []*Column

func (*Table) IsEmpty

func (t *Table) IsEmpty() bool

Jump to

Keyboard shortcuts

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