template

package
v2.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultViewModel = DefaultTableModel

DefaultViewModel is default view template implementation

Functions

func ProcessSchema

func ProcessSchema(dirPath string, schemaMetaData metadata.Schema, generatorTemplate Template) error

ProcessSchema will process schema metadata and constructs go files using generator Template

Types

type EnumModel

type EnumModel struct {
	Skip      bool
	FileName  string
	TypeName  string
	ValueName func(value string) string
}

EnumModel is template for enum model files generation

func DefaultEnumModel

func DefaultEnumModel(enumMetaData metadata.Enum) EnumModel

DefaultEnumModel returns default implementation for EnumModel

func (EnumModel) UseFileName

func (em EnumModel) UseFileName(fileName string) EnumModel

UseFileName returns new EnumModel with new file name set

func (EnumModel) UseTypeName

func (em EnumModel) UseTypeName(typeName string) EnumModel

UseTypeName returns new EnumModel with new type name set

type EnumSQLBuilder

type EnumSQLBuilder struct {
	Skip         bool
	Path         string
	FileName     string
	InstanceName string
	ValueName    func(enumValue string) string
}

EnumSQLBuilder is template for generating enum SQLBuilder files

func DefaultEnumSQLBuilder

func DefaultEnumSQLBuilder(enumMetaData metadata.Enum) EnumSQLBuilder

DefaultEnumSQLBuilder returns default implementation of EnumSQLBuilder

func (EnumSQLBuilder) PackageName

func (e EnumSQLBuilder) PackageName() string

PackageName returns enum sql builder package name

func (EnumSQLBuilder) UseFileName

func (e EnumSQLBuilder) UseFileName(name string) EnumSQLBuilder

UseFileName returns new EnumSQLBuilder with new file name set

func (EnumSQLBuilder) UseInstanceName

func (e EnumSQLBuilder) UseInstanceName(name string) EnumSQLBuilder

UseInstanceName returns new EnumSQLBuilder with instance name set

func (EnumSQLBuilder) UsePath

func (e EnumSQLBuilder) UsePath(path string) EnumSQLBuilder

UsePath returns new EnumSQLBuilder with new path set

type Model

type Model struct {
	Skip  bool
	Path  string
	Table func(table metadata.Table) TableModel
	View  func(table metadata.Table) ViewModel
	Enum  func(enum metadata.Enum) EnumModel
}

Model is template for model files generation

func DefaultModel

func DefaultModel() Model

DefaultModel returns default Model template implementation

func (Model) PackageName

func (m Model) PackageName() string

PackageName returns package name of model types

func (Model) UseEnum

func (m Model) UseEnum(enumFunc func(enumMetaData metadata.Enum) EnumModel) Model

UseEnum returns new Model template with replaced template for enum model files generation

func (Model) UsePath

func (m Model) UsePath(path string) Model

UsePath returns new Model template with replaced file path

func (Model) UseTable

func (m Model) UseTable(tableModelFunc func(table metadata.Table) TableModel) Model

UseTable returns new Model template with replaced template for table model files generation

func (Model) UseView

func (m Model) UseView(tableModelFunc func(table metadata.Table) TableModel) Model

UseView returns new Model template with replaced template for view model files generation

type SQLBuilder

type SQLBuilder struct {
	Skip  bool
	Path  string
	Table func(table metadata.Table) TableSQLBuilder
	View  func(view metadata.Table) TableSQLBuilder
	Enum  func(enum metadata.Enum) EnumSQLBuilder
}

SQLBuilder is template for generating sql builder files

func DefaultSQLBuilder

func DefaultSQLBuilder() SQLBuilder

DefaultSQLBuilder returns default SQLBuilder implementation

func (SQLBuilder) UseEnum

func (sb SQLBuilder) UseEnum(enumFunc func(enum metadata.Enum) EnumSQLBuilder) SQLBuilder

UseEnum returns new SQLBuilder with new EnumSQLBuilder template function set

func (SQLBuilder) UsePath

func (sb SQLBuilder) UsePath(path string) SQLBuilder

UsePath returns new SQLBuilder with new relative path set

func (SQLBuilder) UseTable

func (sb SQLBuilder) UseTable(tableFunc func(table metadata.Table) TableSQLBuilder) SQLBuilder

UseTable returns new SQLBuilder with new TableSQLBuilder template function set

func (SQLBuilder) UseView

func (sb SQLBuilder) UseView(viewFunc func(table metadata.Table) ViewSQLBuilder) SQLBuilder

UseView returns new SQLBuilder with new ViewSQLBuilder template function set

type Schema

type Schema struct {
	Path       string
	Model      Model
	SQLBuilder SQLBuilder
}

Schema is schema generator template used to generate schema(model and sql builder) files

func DefaultSchema

func DefaultSchema(schemaMetaData metadata.Schema) Schema

DefaultSchema returns default schema template implementation

func (Schema) UseModel

func (s Schema) UseModel(model Model) Schema

UseModel returns new schema template with replaced template for model files generation

func (Schema) UsePath

func (s Schema) UsePath(path string) Schema

UsePath replaces path and returns new schema template

func (Schema) UseSQLBuilder

func (s Schema) UseSQLBuilder(sqlBuilder SQLBuilder) Schema

UseSQLBuilder returns new schema with replaced template for sql builder files generation

type TableModel

type TableModel struct {
	Skip     bool
	FileName string
	TypeName string
	Field    func(columnMetaData metadata.Column) TableModelField
}

TableModel is template for table model files generation

func DefaultTableModel

func DefaultTableModel(tableMetaData metadata.Table) TableModel

DefaultTableModel is default table template implementation

func (TableModel) UseField

func (t TableModel) UseField(structFieldFunc func(columnMetaData metadata.Column) TableModelField) TableModel

UseField returns new TableModel with new TableModelField template function

func (TableModel) UseFileName

func (t TableModel) UseFileName(fileName string) TableModel

UseFileName returns new TableModel with new file name set

func (TableModel) UseTypeName

func (t TableModel) UseTypeName(typeName string) TableModel

UseTypeName returns new TableModel with new type name set

type TableModelField

type TableModelField struct {
	Name string
	Type Type
	Tags []string
}

TableModelField is template for table model field generation

func DefaultTableModelField

func DefaultTableModelField(columnMetaData metadata.Column) TableModelField

DefaultTableModelField returns default TableModelField implementation

func (TableModelField) TagsString

func (f TableModelField) TagsString() string

TagsString returns tags string representation

func (TableModelField) UseName

func (f TableModelField) UseName(name string) TableModelField

UseName returns new TableModelField implementation with new field name set

func (TableModelField) UseTags

func (f TableModelField) UseTags(tags ...string) TableModelField

UseTags returns new TableModelField implementation with additional tags added.

func (TableModelField) UseType

func (f TableModelField) UseType(t Type) TableModelField

UseType returns new TypeModelField with a new field type set

type TableSQLBuilder

type TableSQLBuilder struct {
	Skip         bool
	Path         string
	FileName     string
	InstanceName string
	TypeName     string
	DefaultAlias string
	Column       func(columnMetaData metadata.Column) TableSQLBuilderColumn
}

TableSQLBuilder is template for generating table SQLBuilder files

func DefaultTableSQLBuilder

func DefaultTableSQLBuilder(tableMetaData metadata.Table) TableSQLBuilder

DefaultTableSQLBuilder returns default implementation for TableSQLBuilder

func (TableSQLBuilder) PackageName

func (tb TableSQLBuilder) PackageName() string

PackageName returns package name of table sql builder types

func (TableSQLBuilder) UseColumn

func (tb TableSQLBuilder) UseColumn(columnsFunc func(column metadata.Column) TableSQLBuilderColumn) TableSQLBuilder

UseColumn returns new TableSQLBuilder with new column template function set

func (TableSQLBuilder) UseDefaultAlias

func (tb TableSQLBuilder) UseDefaultAlias(defaultAlias string) TableSQLBuilder

UseDefaultAlias returns new TableSQLBuilder with new default alias set

func (TableSQLBuilder) UseFileName

func (tb TableSQLBuilder) UseFileName(name string) TableSQLBuilder

UseFileName returns new TableSQLBuilder with new file name set

func (TableSQLBuilder) UseInstanceName

func (tb TableSQLBuilder) UseInstanceName(name string) TableSQLBuilder

UseInstanceName returns new TableSQLBuilder with new instance name set

func (TableSQLBuilder) UsePath

func (tb TableSQLBuilder) UsePath(path string) TableSQLBuilder

UsePath returns new TableSQLBuilder with new relative path set

func (TableSQLBuilder) UseTypeName

func (tb TableSQLBuilder) UseTypeName(name string) TableSQLBuilder

UseTypeName returns new TableSQLBuilder with new type name set

type TableSQLBuilderColumn

type TableSQLBuilderColumn struct {
	Name string
	Type string
}

TableSQLBuilderColumn is template for table sql builder column

func DefaultTableSQLBuilderColumn

func DefaultTableSQLBuilderColumn(columnMetaData metadata.Column) TableSQLBuilderColumn

DefaultTableSQLBuilderColumn returns default implementation of TableSQLBuilderColumn

type Template

type Template struct {
	Dialect jet.Dialect
	Schema  func(schemaMetaData metadata.Schema) Schema
}

Template is generator template used for file generation

func Default

func Default(dialect jet.Dialect) Template

Default is default generator template implementation

func (Template) UseSchema

func (t Template) UseSchema(schemaFunc func(schemaMetaData metadata.Schema) Schema) Template

UseSchema replaces current schema generate function with a new implementation and returns new generator template

type Type

type Type struct {
	ImportPath string
	Name       string
}

Type represents type of the struct field

func NewType

func NewType(dummyObject interface{}) Type

NewType creates new type for dummy object

type ViewModel

type ViewModel = TableModel

ViewModel is template for view model files generation

type ViewSQLBuilder

type ViewSQLBuilder = TableSQLBuilder

ViewSQLBuilder is template for generating view SQLBuilder files

func DefaultViewSQLBuilder

func DefaultViewSQLBuilder(viewMetaData metadata.Table) ViewSQLBuilder

DefaultViewSQLBuilder returns default implementation for ViewSQLBuilder

Jump to

Keyboard shortcuts

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