model

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 4 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 {
	ProjectPath  string     `yaml:"project_path"`
	ModuleName   ModuleName `yaml:"module_name"`
	Model        string     `yaml:"model"`
	Table        string     `yaml:"table"`
	TableComment string     `yaml:"table_comment"`
	Layers       []string   `yaml:"layers"`
	Fields       Fields     `yaml:"fields"`
	TimeType     TimeEnum   `yaml:"time_type"`
	IDType       IDEnum     `yaml:"id_type"`
	Architecture string
}

Config model to map configuration from a yaml file

func (*Config) AddDefaultInitLayers

func (c *Config) AddDefaultInitLayers()

func (Config) HasValidIDType added in v1.3.0

func (c Config) HasValidIDType() bool

func (Config) HasValidTimeType added in v1.3.0

func (c Config) HasValidTimeType() bool

func (Config) IsProjectPathEmpty

func (c Config) IsProjectPathEmpty() bool

func (Config) IsStorageLayerRequired added in v1.5.0

func (c Config) IsStorageLayerRequired() bool

func (*Config) SetInitPath

func (c *Config) SetInitPath(moduleName ModuleName) error

type Field

type Field struct {
	Name             string `yaml:"name"`
	Type             string `yaml:"type"`
	IsNull           bool   `yaml:"is_null"`
	FieldSize        int    `yaml:"field_size"`
	NumericPrecision uint   `yaml:"numeric_precision"`
	NumericScale     int    `yaml:"numeric_scale"`
}

Field model for every Field of a struct and table that want to be generated

type Fields

type Fields []Field

Fields slice of Field

type IDEnum added in v1.3.0

type IDEnum string
const (
	IDUint IDEnum = "uint"
	IDUUID IDEnum = "uuid.UUID"
)

type Layer

type Layer struct {
	Model        string
	Table        string
	TableComment string
	Fields       Fields

	// ProjectPath indicates the root location of the project
	ProjectPath string

	// ModuleName is used to build the imports
	ModuleName ModuleName

	TimeType TimeEnum `yaml:"time_type"`
	IDType   IDEnum   `yaml:"id_type"`

	// IsStorageLayerGenerated we need this to know if we'll pass this dependency to the domain
	// in the routes layer
	IsStorageLayerGenerated bool `yaml:"is_storage_layer_generated"`
}

func NewLayer

func NewLayer(conf Config) Layer

NewLayer returns a new Layer with module and table Field initialized

func (*Layer) GetPath

func (l *Layer) GetPath(layerName, filename string, withPackage bool) string

type ModuleName

type ModuleName string

func (ModuleName) GetProjectName

func (m ModuleName) GetProjectName() string

type Template

type Template struct {
	Name        string
	Filename    string
	Path        string
	WithPackage bool
	Layer       Layer
}

Template is used to pass the data to create a template

func (*Template) SetLayerData

func (t *Template) SetLayerData(data Layer)

func (*Template) SetPathPrefix

func (t *Template) SetPathPrefix(data Layer)

type Templates

type Templates []Template

Templates slice of Template

func (Templates) SetPath

func (t Templates) SetPath(path string)

SetPath is used when the path is the same for every template

type TimeEnum added in v1.3.0

type TimeEnum string
const (
	Timestamp TimeEnum = "time.Time"
	TimeUnix  TimeEnum = "int64"
)

Jump to

Keyboard shortcuts

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