generator

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFields

func CheckFields(table *builder.Table, fieldNames ...string) (cols builder.Columns, err error)

func WithDefaults

func WithDefaults(dataType string, withDefaults bool, defaultValue string) string

Types

type Config

type Config struct {
	StructName string
	TableName  string
	Database   string

	WithComments        bool
	WithTableInterfaces bool

	FieldPrimaryKey    string
	FieldKeySoftDelete string
	FieldKeyCreatedAt  string
	FieldKeyUpdatedAt  string

	ConstSoftDeleteTrue  string
	ConstSoftDeleteFalse string
}

func (*Config) SetDefaults

func (g *Config) SetDefaults()

type DataTypeDescriber added in v1.1.1

type DataTypeDescriber interface {
	DateType() string
}

type Keys

type Keys struct {
	Primary        builder.FieldNames
	Indexes        builder.Indexes
	UniqueIndexes  builder.Indexes
	SpatialIndexes 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
	FieldKeyAutoIncrement string
	HasSoftDelete         bool
	HasCreatedAt          bool
	HasUpdatedAt          bool
	HasAutoIncrement      bool
}

func NewModel

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

func (*Model) FieldType

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

func (*Model) GetComments

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

func (*Model) IndexFieldNames

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

func (*Model) PtrType

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

func (*Model) SnippetDisableIfNeedForFieldValues

func (m *Model) SnippetDisableIfNeedForFieldValues(file *codegen.File) codegen.Snippet

func (*Model) SnippetEnableIfNeed

func (m *Model) SnippetEnableIfNeed(file *codegen.File) codegen.Snippet

func (*Model) SnippetEnableIfNeedForFieldValues

func (m *Model) SnippetEnableIfNeedForFieldValues(file *codegen.File) codegen.Snippet

func (*Model) SnippetSetCreatedAtIfNeed

func (m *Model) SnippetSetCreatedAtIfNeed(file *codegen.File) codegen.Snippet

func (*Model) SnippetSetLastInsertIdIfNeed

func (m *Model) SnippetSetLastInsertIdIfNeed(file *codegen.File) codegen.Snippet

func (*Model) SnippetSetUpdatedAtIfNeed

func (m *Model) SnippetSetUpdatedAtIfNeed(file *codegen.File) codegen.Snippet

func (*Model) SnippetSetUpdatedAtIfNeedForFieldValues

func (m *Model) SnippetSetUpdatedAtIfNeedForFieldValues(file *codegen.File) codegen.Snippet

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) 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()

type TagGenerator

type TagGenerator struct {
	WithDefaults bool
	// contains filtered or unexported fields
}

func NewTagGenerator

func NewTagGenerator(pkg *packagesx.Package) *TagGenerator

func (*TagGenerator) Output

func (g *TagGenerator) Output(cwd string)

func (*TagGenerator) Scan

func (g *TagGenerator) Scan(structNames ...string)

Directories

Path Synopsis
__examples__

Jump to

Keyboard shortcuts

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