generate

package
v0.0.0-...-61e71c0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenModel

func GenModel(c *cli.Context) error

GenModel is used to generate a new model

func SubCommands

func SubCommands() []cli.Command

SubCommands returns a list of SubCommands for the "generate"" command

Types

type Model

type Model struct {
	// Name contains the name of the Model
	Name string

	// Table contains the name of the SQL table
	Table string

	// FileName cotains the name of the file containing the model
	FileName string

	// PackageName cotains the name of the package containing the model
	PackageName string

	// FullPath cotains the path to the file containing the model
	FullPath string

	// Fields cotains all the fields of the model
	Fields []*ModelField

	// Excluded contains all the method not to generate
	Excluded []string

	// IsSingle is used to name the CRUD methods accordingly to the package
	// Example: here's the name of the finder by id depending on IsSingle
	// false, GetUserByID
	// true: GetByID
	IsSingle bool

	// UseUUID is used to auto-populate the ID fields
	UseUUID bool
}

Model represent a model to generate

func (*Model) Parse

func (m *Model) Parse() error

Parse parses and render a model

type ModelField

type ModelField struct {
	Name   string
	DbName string
}

ModelField represents a field from the struct we are parsing

type ModelTemplateVars

type ModelTemplateVars struct {
	ModelName      string
	ModelNameLC    string
	TableName      string
	ModelVar       string
	PackageName    string
	CreateStmt     string
	CreateStmtArgs string
	UpdateStmt     string
	UpdateStmtArgs string
	FieldsAsArray  string
	Excluded       []string
	IsSingle       bool
	UseUUID        bool
}

ModelTemplateVars contains all the variable needed to render the new file

func (*ModelTemplateVars) Generate

func (mtv *ModelTemplateVars) Generate(wanted string) bool

Generate returns true if the element has not been excluded

func (*ModelTemplateVars) OptionalName

func (mtv *ModelTemplateVars) OptionalName() string

OptionalName returns the model name if single is set to false. returns an empty string otherwise

Jump to

Keyboard shortcuts

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