generate

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStructNames

func GetStructNames(bases []*StructMeta) (names []string)

GetStructNames get struct names from base structs

Types

type ITableInfo

type ITableInfo interface {
	GetTableColumns(schemaName string, tableName string) (result []*model.Column, err error)

	GetTableIndex(schemaName string, tableName string) (indexes []gorm.Index, err error)
}

ITableInfo table info interface

type StructMeta added in v1.0.0

type StructMeta struct {
	Generated            bool   // whether to generate db model
	FileName             string // generated file name
	S                    string // the first letter(lower case)of simple Name (receiver)
	QueryStructName      string // internal query struct name
	ModelStructName      string // origin/model struct name
	TableName            string // table name in db server
	TableComment         string // table comment in db server
	Fields               []*model.Field
	ImportPkgPaths       []string
	TemplatePkgPath      map[string]string // 模板的包路径
	PkgPath              string            // package's path: internal/model
	Package              string            // package's name: model
	Type                 string            // param's type: User
	ConvTypeMap          map[string]string
	ConvTypePkgMap       map[string]string
	DynamicConstSuffixes []string            // dynamic const suffix
	AutoValueFields      map[string]struct{} // dynamic const suffix
	FieldWithTags        []string
	// contains filtered or unexported fields
}

func ConvertStructs

func ConvertStructs(db *gorm.DB, structs ...interface{}) (metas []*StructMeta, err error)

ConvertStructs convert to base structures

func GetStructMeta added in v1.0.0

func GetStructMeta(db *gorm.DB, conf *model.Config) (*StructMeta, error)

GetStructMeta generate db model by table name

Jump to

Keyboard shortcuts

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