inflect

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Singular = rules.Singularize
View Source
var Tableize = inflect.Tableize
View Source
var TemplateFunctions = template.FuncMap{
	"lower":                     strings.ToLower,
	"upper":                     strings.ToUpper,
	"pascal":                    Pascal,
	"plural":                    plural,
	"singular":                  rules.Singularize,
	"goType":                    goType,
	"goInputType":               goInputType,
	"customType":                customType,
	"columnType":                columnType,
	"snake":                     Snake,
	"join":                      strings.Join,
	"camel":                     camel,
	"firstWordUpperCamel":       firstWordUpperCamel,
	"firstWordLowerCamel":       firstWordLowerCamel,
	"firstLetterLower":          firstLetterLower,
	"sub":                       sub,
	"add":                       add,
	"hasManyWithNoThrough":      hasManyWithNoThrough,
	"hasManyWithThrough":        hasManyWithThrough,
	"checkVariable":             checkVariable,
	"delVariable":               delVariable,
	"addStr":                    addStr,
	"isAssociation":             isAssociation,
	"isOnlyBelongTo":            isOnlyBelongTo,
	"getHasOne":                 getHasOne,
	"getTableNameOfBelongTo":    getTableNameOfBelongTo,
	"getTableNameOfHasOne":      getTableNameOfHasOne,
	"getTableNameOfHasMany":     getTableNameOfHasMany,
	"getTableNameOfThrough":     getTableNameOfThrough,
	"getTableNameFromModelName": getTableNameFromModelName,

	"goChangeSetType": goChangeSetType,
	"goKeywordFix":    goKeywordFix,
	"goModelType":     goModelType,
}

TODO: move to template generator

Functions

func Pascal

func Pascal(s string) string

func Snake

func Snake(s string) string

Types

type BelongsTo

type BelongsTo struct {
	Name        string
	ModelName   string
	ForeignKey  string
	ForeignType string
	PrimaryKey  string
	Dependent   string
	Optional    bool
	Required    bool
	Default     bool
}

type Database

type Database struct {
	Name    string
	Adapter string
	Models  []*Model
}

type HasMany

type HasMany struct {
	Name       string
	ModelName  string
	Through    string
	ForeignKey string
	Source     string
}

type HasOne

type HasOne struct {
	Name       string
	ModelName  string
	Through    string
	ForeignKey string
}

type Model

type Model struct {
	Name       string
	TableName  string
	Timestamps bool
	BelongsTo  []*BelongsTo
	HasMany    []*HasMany
	HasOne     []*HasOne
}

为了避免循环依赖,没有直接引用schema.Model

Jump to

Keyboard shortcuts

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