go-zero/tools/goctl/model/sql/template/insert.go

9 lines
392 B
Go
Raw Normal View History

package template
2020-07-29 17:11:41 +08:00
var Insert = `
func (m *{{.upperStartCamelObject}}Model) Insert(data {{.upperStartCamelObject}}) (sql.Result, error) {
query := ` + "`" + `insert into ` + "`" + ` + m.table + ` + "`(` + " + `{{.lowerStartCamelObject}}RowsExpectAutoSet` + " + `) value ({{.expression}})` " + `
return m.{{if .withCache}}ExecNoCache{{else}}conn.Exec{{end}}(query, {{.expressionValues}})
2020-07-29 17:11:41 +08:00
}
`