model

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: Apache-2.0 Imports: 6 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 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 DbColumn

type DbColumn struct {
	Name            string `db:"COLUMN_NAME"`
	DataType        string `db:"DATA_TYPE"`
	ColumnType      string `db:"COLUMN_TYPE"`
	Extra           string `db:"EXTRA"`
	Comment         string `db:"COLUMN_COMMENT"`
	ColumnDefault   any    `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) ([]string, error)

GetAllTables selects all tables from TABLE_SCHEMA

type PostgreColumn

type PostgreColumn struct {
	Num               sql.NullInt32  `db:"num"`
	Field             sql.NullString `db:"field"`
	Type              sql.NullString `db:"type"`
	NotNull           sql.NullBool   `db:"not_null"`
	Comment           sql.NullString `db:"comment"`
	ColumnDefault     sql.NullString `db:"column_default"`
	IdentityIncrement sql.NullInt32  `db:"identity_increment"`
}

PostgreColumn describes a column in table

type PostgreIndex

type PostgreIndex struct {
	IndexName  sql.NullString `db:"index_name"`
	IndexId    sql.NullInt32  `db:"index_id"`
	IsUnique   sql.NullBool   `db:"is_unique"`
	IsPrimary  sql.NullBool   `db:"is_primary"`
	ColumnName sql.NullString `db:"column_name"`
	IndexSort  sql.NullInt32  `db:"index_sort"`
}

PostgreIndex describes an index for a column

type PostgreSqlModel

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

PostgreSqlModel gets table information from information_schema、pg_catalog

func NewPostgreSqlModel

func NewPostgreSqlModel(conn sqlx.SqlConn) *PostgreSqlModel

NewPostgreSqlModel creates an instance and return

func (*PostgreSqlModel) FindColumns

func (m *PostgreSqlModel) FindColumns(schema, table string) (*ColumnData, error)

FindColumns return columns in specified database and table

func (*PostgreSqlModel) FindIndex

func (m *PostgreSqlModel) FindIndex(schema, table string) ([]*PostgreIndex, error)

FindIndex finds index with given schema, table and column.

func (*PostgreSqlModel) GetAllTables

func (m *PostgreSqlModel) GetAllTables(schema string) ([]string, error)

GetAllTables selects all tables from TABLE_SCHEMA

type Table

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

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