inflect

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 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,
	"snake":                 Snake,
	"join":                  strings.Join,
	"camel":                 camel,
	"firstWordUpperCamel":   firstWordUpperCamel,
	"firstWordLowerCamel":   firstWordLowerCamel,
	"firstLetterLower":      firstLetterLower,
	"sub":                   sub,
	"add":                   add,
	"addStr":                addStr,
	"getTableNameOfHasMany": getTableNameOfHasMany,
	"getTableNameOfThrough": getTableNameOfThrough,

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

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