model

package
v0.0.0-...-6d6c219 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAltName

func BuildAltName(name, mode string) string

func SqlTypeToProper

func SqlTypeToProper(abbr string) string

func StorageTypeToProper

func StorageTypeToProper(abbr string) string

func TagFormatToProper

func TagFormatToProper(tag string) string

Types

type Column

type Column struct {
	ColumnName   Name
	DBType       string
	GoType       string
	GoTypeNonSql string
	Null         bool
	DefaultValue string
	Length       int64
	PrimaryKey   bool
	IsNoSQLUUID  bool
}

type ColumnExistence

type ColumnExistence struct {
	HaveNullColumns bool
	TimeColumn      bool
}

type ColumnTest

type ColumnTest struct {
	GoType string
	DBType string
}

type Entity

type Entity struct {
	Columns       []Column
	SqlLines      []string
	DefaultColumn string
	SortColumns   string
	ModuleName    string
	GrpcImport    string
	MultipleKeys  bool
	Name
	ColumnExistence
}

func (*Entity) HasJsonColumn

func (e *Entity) HasJsonColumn() bool

func (*Entity) HasNullColumn

func (e *Entity) HasNullColumn() bool

func (*Entity) HasNullTimeColumn

func (e *Entity) HasNullTimeColumn() bool

func (*Entity) HasPrimaryKeyString

func (e *Entity) HasPrimaryKeyString() bool

func (*Entity) HasPrimaryUUIDColumn

func (e *Entity) HasPrimaryUUIDColumn() bool

func (*Entity) HasTimeColumn

func (e *Entity) HasTimeColumn() bool

type FileTemplate

type FileTemplate struct {
	FileKeys       string
	FileGetColumns string
	FilePostIncr   string
}

type Format

type Format struct {
	Name string
}

type GrpcTemplate

type GrpcTemplate struct {
	GrpcArgsInit     string
	GrpcTranslateIn  string
	GrpcTranslateOut string
	GrpcImport       string
}

type ManagerTemplate

type ManagerTemplate struct {
	ManagerTestImport    string
	ManagerTestGetRow    string
	ManagerTestPostRow   string
	ManagerTestPatchInit string
	ManagerTestDeleteRow string
	ManagerImport        string
	ManagerGetRows       string
	ManagerPostRows      string
	ManagerPatchInitArgs string
	ManagerInitArgsMongo string
	ManagerPatchRows     string
	ManagerAuditKey      string
}

type MigrationVars

type MigrationVars struct {
	MigrationHeader     string
	MigrationConnection string
	MigrationVerify     string
}

rename to Template

type ModelTemplate

type ModelTemplate struct {
	ModelImport      string
	ModelRows        string
	ModelInitStorage string
}

type Name

type Name struct {
	RawName    string `json:"-"` // name given by the user/script
	Lower      string `json:"-"`
	Camel      string `json:"-"`
	LowerCamel string `json:"-"`
	Abbr       string `json:"-"`
	AllLower   string `json:"-"`
	Upper      string `json:"-"`
	EnvVar     string `json:"-"`
	KebabCase  string `json:"-"`
}

func (*Name) BuildName

func (n *Name) BuildName(name string, knownAliases []string) string

func (*Name) DetermineAbbr

func (n *Name) DetermineAbbr(knownAliases []string) string

type PostPutTest

type PostPutTest struct {
	Name         string
	ForColumn    string
	ColumnLength int
	Failure      bool
}

type Project

type Project struct {
	UseBlank              bool
	Entities              []Entity
	ProjectNameAllLower   string
	ProjectNameLower      string
	ProjectNameCamel      string
	ProjectNameAbbr       string
	ProjectNameLowerCamel string
	ProjectNameEnv        string
	// SQLProvider           string // optional if using SQL as a storage, either Psql, MySql or Sqlite; this interfaces with sqlx
	// SQLProviderLower      string // optional is using SQL, lowercase of above
	CurrentEntity Entity // rotating entity or templating, will be emptied out after processing
	ProjectFile
	FileTemplate
	GrpcTemplate
	ManagerTemplate
	ModelTemplate
	RestTemplate
	StorageTemplate
	StorageVars
	MigrationVars
}

type ProjectFile

type ProjectFile struct {
	Message              string   `json:"message"`
	AppName              string   `json:"app_name"`
	FullPath             string   `json:"full_path"`    // full path to the project
	SubDir               string   `json:"sub_dir"`      // directory, only, you will save the files to
	SubPackage           string   `json:"sub_package"`  // if sub directory is multipath i.e. internal/v1, will be used for package name
	ProjectPath          string   `json:"project_path"` // fullpath minus gopath/src; used for import statements
	Storage              string   `json:"storage"`
	SqlStorage           string   `json:"sql_storage"`
	ProjectPathEncoded   string   `json:"project_path_encoded"`   // encode to use in some of the templating
	SubDirEncoded        string   `json:"sub_dir_encoded"`        // encode to use in some of the templating
	DynamicSchema        bool     `json:"dynamic_schema"`         // TODO: this is for postgres, need to add an ability to add it
	Schema               string   `json:"schema"`                 // TODO: this is for postgres, need to add an ability to add it
	DynamicSchemaPostfix string   `json:"dynamic_schema_postfix"` // TODO: might not need anymore
	UseORM               bool     `json:"use_orm"`
	TagFormat            string   `json:"tag_format"`
	KnownAliases         []string `json:"known_aliases"`
	VersionPath          string   `json:"version_path"` // TODO: make an option to change this
	Modules              []string `json:"modules"`
	LoadedConfig         bool     `json:"loaded_config"` // tells the code to only run once
	Name
}

func (*ProjectFile) CreateProjectFile

func (p *ProjectFile) CreateProjectFile(pwd string) bool

func (*ProjectFile) LoadProjectFile

func (p *ProjectFile) LoadProjectFile() bool

func (*ProjectFile) SaveProjectFile

func (p *ProjectFile) SaveProjectFile()

type RestTemplate

type RestTemplate struct {
	RestStrConv         string
	RestGetDeleteUrl    string
	RestGetDeleteAssign string
	RestArgSet          string
	RestImport          string
}

type SqlEntity

type SqlEntity struct {
	Name         string
	Columns      []Column
	ColExistence ColumnExistence
}

type StorageTemplate

type StorageTemplate struct {
	StorageTable          string
	StorageTablePrefix    string
	StorageTablePostfix   string
	StorageGetColumns     string
	StorageTableKeyKeys   string
	StorageTableKeyValues string
	// StorageTableKeyListOrder string
	StoragePostColumns      string
	StoragePostColumnsNamed string
	StoragePostReturning    string
	StoragePostQuery        string
	StoragePostLastId       string
	StoragePatchColumns     string
	StoragePatchWhere       string
	StoragePatchWhereValues string
	StorageImport           string
	StorageCountCall        string
	StorageCountFunc        string
	StorageCountImport      string
}

type StorageVars

type StorageVars struct {
	SQLProvider           string // optional if using SQL as a storage, either Psql, MySql or Sqlite; this interfaces with sqlx
	SQLProviderLower      string // optional if using SQL as a storage, either psql, mysql or sqlite; this interfaces with gorm
	SQLProviderConnection string // holds the connection string for gorm of the other sql types
}

Jump to

Keyboard shortcuts

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