generator

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StructName string
	TableName  string
	Database   string

	WithComments        bool
	WithTableName       bool
	WithTableInterfaces bool
	WithMethods         bool

	FieldPrimaryKey   string
	FieldKeyDeletedAt string
	FieldKeyCreatedAt string
	FieldKeyUpdatedAt string
}

func (*Config) SetDefaults

func (g *Config) SetDefaults()

type Keys

type Keys struct {
	Primary       []string
	Indexes       builder.Indexes
	UniqueIndexes builder.Indexes
}

func (*Keys) Bind

func (ks *Keys) Bind(table *builder.Table)

func (*Keys) PatchUniqueIndexesWithSoftDelete

func (ks *Keys) PatchUniqueIndexesWithSoftDelete(softDeleteField string)

type Model

type Model struct {
	*types.TypeName
	*Config
	*Keys
	*builder.Table
	Fields                map[string]*types.Var
	StructFields          []*builder.StructField
	FieldKeyAutoIncrement string
	HasDeletedAt          bool
	HasCreatedAt          bool
	HasUpdatedAt          bool
	HasAutoIncrement      bool
}

func NewModel

func NewModel(pkg *packagesx.Package, typeName *types.TypeName, comments string, cfg *Config) *Model

func NewModelsFromDataBase added in v1.0.2

func NewModelsFromDataBase(s *sqlx.Database) []*Model

func (*Model) BasicDataType added in v1.0.2

func (m *Model) BasicDataType(columnType *builder.ColumnType) reflect.Type

func (*Model) ColumnTag added in v1.0.2

func (m *Model) ColumnTag(column *builder.Column) map[string]reflectx.StructTag

func (*Model) FieldType

func (m *Model) FieldType(file *codegen.File, fieldName string) codegen.SnippetType

func (*Model) Generator added in v1.0.2

func (m *Model) Generator() error

func (*Model) GetColDescriptions

func (m *Model) GetColDescriptions() map[string][]string

func (*Model) GetComments

func (m *Model) GetComments() map[string]string

func (*Model) GetRelations

func (m *Model) GetRelations() map[string][]string

func (*Model) IndexFieldNames

func (m *Model) IndexFieldNames() []string

func (*Model) IteratorType

func (m *Model) IteratorType() codegen.SnippetType

func (*Model) PtrType

func (m *Model) PtrType() codegen.SnippetType

func (*Model) Type

func (m *Model) Type() codegen.SnippetType

func (*Model) VarTable

func (m *Model) VarTable() string

func (*Model) WriteBatchList

func (m *Model) WriteBatchList(file *codegen.File)

func (*Model) WriteByKey

func (m *Model) WriteByKey(file *codegen.File)

func (*Model) WriteCRUD

func (m *Model) WriteCRUD(file *codegen.File)

func (*Model) WriteCount

func (m *Model) WriteCount(file *codegen.File)

func (*Model) WriteCreate

func (m *Model) WriteCreate(file *codegen.File)

func (*Model) WriteDelete

func (m *Model) WriteDelete(file *codegen.File)

func (*Model) WriteList

func (m *Model) WriteList(file *codegen.File)

func (*Model) WriteTableInterfaces

func (m *Model) WriteTableInterfaces(file *codegen.File)

func (*Model) WriteTableKeyInterfaces

func (m *Model) WriteTableKeyInterfaces(file *codegen.File)

func (*Model) WriteTableName

func (m *Model) WriteTableName(file *codegen.File)

func (*Model) WriteTo

func (m *Model) WriteTo(file *codegen.File)

type SqlFuncGenerator

type SqlFuncGenerator struct {
	Config
	// contains filtered or unexported fields
}

func NewSqlFuncGenerator

func NewSqlFuncGenerator(pkg *packagesx.Package) *SqlFuncGenerator

func (*SqlFuncGenerator) Output

func (g *SqlFuncGenerator) Output(cwd string)

func (*SqlFuncGenerator) Scan

func (g *SqlFuncGenerator) Scan()

Directories

Path Synopsis
__examples__

Jump to

Keyboard shortcuts

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