gen

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 17 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Category

func Category() string

Category returns model const value

func Clean

func Clean() error

Clean deletes all template files

func GenTemplates

func GenTemplates() error

GenTemplates creates template files if not exists

func NewDefaultGenerator

func NewDefaultGenerator(dir string, cfg *config.Config, opt ...Option) (*defaultGenerator, error)

NewDefaultGenerator creates an instance for defaultGenerator

func RevertTemplate

func RevertTemplate(name string) error

RevertTemplate reverts the deleted template files

func Update

func Update() error

Update provides template clean and init

Types

type Field added in v1.6.5

type Field struct {
	NameOriginal    string
	UpperName       string
	LowerName       string
	DataType        string
	Comment         string
	SeqInIndex      int
	OrdinalPosition int
}

Field describes a table field

type Join

type Join []string

Join describes an alias of string slice

func (Join) Camel

func (j Join) Camel() Join

Camel convert items into Camel and return

func (Join) Lower

func (j Join) Lower() Join

Lower convert items into Lower and return

func (Join) Snake

func (j Join) Snake() Join

Snake convert items into Snake and return

func (Join) Title

func (j Join) Title() Join

Title convert items into Title and return

func (Join) Untitle

func (j Join) Untitle() Join

Untitle converts items into Untitle and return

func (Join) Upper

func (j Join) Upper() Join

Upper convert items into Upper and return

func (Join) With

func (j Join) With(sep string) stringx.String

With convert items into With and return

type Key

type Key struct {
	// VarLeft describes the variable of cache key expression which likes cacheUserIdPrefix
	VarLeft string
	// VarRight describes the value of cache key expression which likes "cache:user:id:"
	VarRight string
	// VarExpression describes the cache key expression which likes cacheUserIdPrefix = "cache:user:id:"
	VarExpression string
	// KeyLeft describes the variable of key definition expression which likes userKey
	KeyLeft string
	// KeyRight describes the value of key definition expression which likes fmt.Sprintf("%s%v", cacheUserPrefix, user)
	KeyRight string
	// DataKeyRight describes data key likes fmt.Sprintf("%s%v", cacheUserPrefix, data.User)
	DataKeyRight string
	// KeyExpression describes key expression likes userKey := fmt.Sprintf("%s%v", cacheUserPrefix, user)
	KeyExpression string
	// DataKeyExpression describes data key expression likes userKey := fmt.Sprintf("%s%v", cacheUserPrefix, data.User)
	DataKeyExpression string
	// FieldNameJoin describes the filed slice of table
	FieldNameJoin Join
	// Fields describes the fields of table
	Fields []*parser.Field
}

Key describes cache key

type Option

type Option func(generator *defaultGenerator)

Option defines a function with argument defaultGenerator

func WithConsoleOption

func WithConsoleOption(c console.Console) Option

WithConsoleOption creates a console option.

func WithIgnoreColumns added in v1.4.2

func WithIgnoreColumns(ignoreColumns []string) Option

WithIgnoreColumns ignores the columns while insert or update rows.

func WithPostgreSql

func WithPostgreSql() Option

WithPostgreSql marks defaultGenerator.isPostgreSql true.

type Table

type Table struct {
	parser.Table
	PrimaryCacheKey        Key
	UniqueCacheKey         []Key
	ContainsUniqueCacheKey bool
	// contains filtered or unexported fields
}

Table defines mysql table

Jump to

Keyboard shortcuts

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