orm

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeForMysqlToGo = map[string]string{
	"int":                "int32",
	"integer":            "int32",
	"tinyint":            "int32",
	"smallint":           "int32",
	"mediumint":          "int32",
	"bigint":             "int64",
	"int unsigned":       "uint32",
	"integer unsigned":   "uint32",
	"tinyint unsigned":   "uint32",
	"smallint unsigned":  "uint32",
	"mediumint unsigned": "uint32",
	"bigint unsigned":    "uint64",
	"bit":                "int64",
	"bool":               "bool",
	"enum":               "string",
	"set":                "string",
	"varchar":            "string",
	"char":               "string",
	"tinytext":           "string",
	"mediumtext":         "string",
	"text":               "string",
	"longtext":           "string",
	"blob":               "string",
	"tinyblob":           "string",
	"mediumblob":         "string",
	"longblob":           "string",
	"date":               "database.Time",
	"datetime":           "database.Time",
	"timestamp":          "database.Time",
	"time":               "database.Time",
	"float":              "float64",
	"double":             "float64",
	"decimal":            "float64",
	"binary":             "string",
	"varbinary":          "string",
	"json":               "database.JSON",
}

Functions

func GenMysql

func GenMysql(name string, conf Conf, out string)

func GenSqlite added in v0.5.8

func GenSqlite(table string, goType parser.GoType, out string)

func IsExist

func IsExist(f string) bool

IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.

Types

type Conf

type Conf map[interface{}]interface{}

type DB

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

func NewDb

func NewDb(conf map[interface{}]interface{}) *DB

func (*DB) GetDB added in v0.1.8

func (d *DB) GetDB() *sql.DB

type Relationship added in v0.2.7

type Relationship struct {
	Type              string `json:"type"`               //关联类型:belongs_to、has_one、has_many、many2many
	Table             string `json:"table"`              //关联表名
	Alias             string `json:"alias"`              //别名(可不声明,默认用表名)
	ForeignKey        string `json:"foreign_key"`        //外键(可不声明,默认为'id'或'表名_id')
	ReferenceKey      string `json:"reference_key"`      //引用键(可不声明,默认为'id'或'表名_id')
	RelationshipTable string `json:"relationship_table"` //当many2many时,连接表名
	JoinForeignKey    string `json:"join_foreign_key"`   //当many2many时,本表在连接表的外键
	JoinTargetKey     string `json:"join_target_key"`    //当many2many时,关联表在连接表的外键
}

type TableInfo added in v0.4.0

type TableInfo struct {
	Columns map[string][]tableColumn
	Infos   map[string]TableInfos
}

func Filter added in v0.4.0

func Filter(tableColumns map[string][]tableColumn) TableInfo

Filter 过滤分表格式 table_{0-9} 只返回table

type TableInfos added in v0.4.0

type TableInfos map[string]interface{}

func (TableInfos) IsSub added in v0.4.0

func (t TableInfos) IsSub() bool

Jump to

Keyboard shortcuts

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