Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Delete defines a delete template Delete = `` /* 850-byte string literal not displayed */ // DeleteMethod defines a delete template for interface method DeleteMethod = `Delete(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error` )
View Source
const ( // FindOne defines find row by id. FindOne = `` /* 1141-byte string literal not displayed */ // FindOneByField defines find row by field. FindOneByField = `` /* 1176-byte string literal not displayed */ // FindOneByFieldExtraMethod defines find row by field with extras. FindOneByFieldExtraMethod = `` /* 504-byte string literal not displayed */ // FindOneMethod defines find row method. FindOneMethod = `FindOne(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error)` // FindOneByFieldMethod defines find row by field method. FindOneByFieldMethod = `FindOneBy{{.upperField}}(ctx context.Context, {{.in}}) (*{{.upperStartCamelObject}}, error) ` )
View Source
const ( // Imports defines a import template for model in cache case Imports = `` /* 329-byte string literal not displayed */ // ImportsNoCache defines a import template for model in normal case ImportsNoCache = `` /* 279-byte string literal not displayed */ )
View Source
const ( // Insert defines a template for insert code in model Insert = `` /* 690-byte string literal not displayed */ // InsertMethod defines an interface method template for insert code in model InsertMethod = `Insert(ctx context.Context, data *{{.upperStartCamelObject}}) (sql.Result,error)` )
View Source
const ( // Update defines a template for generating update codes Update = `` /* 977-byte string literal not displayed */ // UpdateMethod defines an interface method template for generating update codes UpdateMethod = `Update(ctx context.Context, {{if .containsIndexCache}}newData{{else}}data{{end}} *{{.upperStartCamelObject}}) error` )
View Source
const Error = `package {{.pkg}}
import "github.com/zeromicro/go-zero/core/stores/sqlx"
var ErrNotFound = sqlx.ErrNotFound
`
Error defines an error template
View Source
const Field = `{{.name}} {{.type}} {{.tag}} {{if .hasComment}}// {{.comment}}{{end}}`
Field defines a filed template for types
View Source
const ModelCustom = `` /* 1039-byte string literal not displayed */
ModelCustom defines a template for extension
View Source
const New = `` /* 303-byte string literal not displayed */
New defines the template for creating model instance.
View Source
const TableName = `
func (m *default{{.upperStartCamelObject}}Model) tableName() string {
return m.table
}
`
TableName defines a template that generate the tableName method.
View Source
const Tag = "`db:\"{{.field}}\"`"
Tag defines a tag template text
View Source
const Types = `` /* 261-byte string literal not displayed */
Types defines a template for types in model.
Variables ¶
View Source
var ModelGen = fmt.Sprintf(`%s package {{.pkg}} {{.imports}} {{.vars}} {{.types}} {{.new}} {{.delete}} {{.find}} {{.insert}} {{.update}} {{.extraMethod}} {{.tableName}} `, util.DoNotEditHead)
ModelGen defines a template for model
View Source
var Vars = fmt.Sprintf(
`
var (
{{.lowerStartCamelObject}}FieldNames = builder.RawFieldNames(&{{.upperStartCamelObject}}{}{{if .postgreSql}},true{{end}})
{{.lowerStartCamelObject}}Rows = strings.Join({{.lowerStartCamelObject}}FieldNames, ",")
{{.lowerStartCamelObject}}RowsExpectAutoSet = {{if .postgreSql}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, {{if .autoIncrement}}"{{.originalPrimaryKey}}",{{end}} "%screate_time%s", "%supdate_time%s", "%screate_t%s", "%supdate_at%s"), ","){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, {{if .autoIncrement}}"{{.originalPrimaryKey}}",{{end}} "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s"), ","){{end}}
{{.lowerStartCamelObject}}RowsWithPlaceHolder = {{if .postgreSql}}builder.PostgreSqlJoin(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s")){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s"), "=?,") + "=?"{{end}}
{{if .withCache}}{{.cacheKeys}}{{end}}
)
`, "", "", "", "", "", "", "", "",
"`", "`", "`", "`", "`", "`", "`", "`",
"", "", "", "", "", "", "", "",
"`", "`", "`", "`", "`", "`", "`", "`",
)
Vars defines a template for var block in model
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.