schema

package
v0.0.0-...-e50112c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbQuery

type DbQuery interface {
	QueryString(sqlOrArgs ...interface{}) ([]mapUtil.StringMap, error)
}

type FieldSchema

type FieldSchema struct {
	ColumnName     string `json:"columnName" description:"列名"`
	ColumnType     string `json:"columnType" description:"列的完整类型(DataType + DataLength)"`
	ColumnNullable bool   `json:"columnNullable,omitempty" description:""`
	ColumnDefault  string `json:"columnDefault,omitempty" description:"列默认值"`
	ColumnComment  string `json:"columnComment,omitempty" description:"列注释"`
	DataType       string `json:"dataType,omitempty" description:"列数据类型"`
	FieldName      string `json:"fieldName,omitempty" description:"对应结构体的字段名"`
	FieldType      string `json:"fieldType,omitempty" description:"对应结构体的字段类型"`
}

func (*FieldSchema) ColumnDefaultVal

func (this *FieldSchema) ColumnDefaultVal() interface{}

func (*FieldSchema) ParseValue

func (this *FieldSchema) ParseValue(val string) interface{}

type IndexSchema

type IndexSchema struct {
	Name    string   `json:"name"`
	Primary bool     `json:"primary,omitempty"`
	Unique  bool     `json:"unique,omitempty"`
	Columns []string `json:"columns,omitempty"`
}

type StructFormatter

type StructFormatter struct {
	NameFormatter      func(database, table string) string
	FieldNameFormatter func(database, table string, column *FieldSchema) string
	FieldTypeFormatter func(database, table string, column *FieldSchema) string
}

type TableSchema

type TableSchema struct {
	Database     string         `json:"database"`
	Table        string         `json:"table"`
	Type         string         `json:"type"`
	StructName   string         `json:"structName,omitempty"`
	TableComment string         `json:"tableComment,omitempty"`
	Fields       []*FieldSchema `json:"fields,omitempty"`
	Indexes      []*IndexSchema `json:"indexes,omitempty"`
}

func GetTableSchema

func GetTableSchema(db DbQuery, database, table string, formatter ...*StructFormatter) (*TableSchema, error)

func (*TableSchema) GetFieldSchema

func (this *TableSchema) GetFieldSchema(column string) *FieldSchema

func (*TableSchema) GetIndexSchema

func (this *TableSchema) GetIndexSchema(columns []string, checkOrder bool) *IndexSchema

func (*TableSchema) GetUniqueSchema

func (this *TableSchema) GetUniqueSchema(columns []string) *IndexSchema

Jump to

Keyboard shortcuts

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