This reverts commit cc4c4928e0.
This commit is contained in:
@@ -30,17 +30,4 @@ var (
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
`
|
||||
// pg
|
||||
ImportsNoCachePg = `import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
{{if .time}}"time"{{end}}
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
`
|
||||
)
|
||||
|
||||
@@ -15,24 +15,5 @@ func (m *default{{.upperStartCamelObject}}Model) Insert(ctx context.Context, dat
|
||||
}
|
||||
`
|
||||
|
||||
// pg
|
||||
var InsertPg = `
|
||||
func (m *default{{.upperStartCamelObject}}Model) Insert(data *{{.upperStartCamelObject}}) (int64,error) {
|
||||
{{if .withCache}}{{if .containsIndexCache}}{{.keys}}
|
||||
ret, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values ({{.expression}})", m.table, {{.lowerStartCamelObject}}RowsExpectAutoSet)
|
||||
return conn.Exec(query, {{.expressionValues}})
|
||||
}, {{.keyValues}}){{else}}query := fmt.Sprintf("insert into %s (%s) values ({{.expression}})", m.table, {{.lowerStartCamelObject}}RowsExpectAutoSet)
|
||||
ret,err:=m.ExecNoCache(query, {{.expressionValues}})
|
||||
{{end}}{{else}}query := fmt.Sprintf("insert into %s (%s) values ({{.expression}}) RETURNING id", m.table, {{.lowerStartCamelObject}}RowsExpectAutoSet)
|
||||
var id int64
|
||||
err:=m.conn.QueryRow(&id, query, {{.expressionValues}}){{end}}
|
||||
return id,err
|
||||
}
|
||||
`
|
||||
|
||||
// InsertMethod defines an interface method template for insert code in model
|
||||
var InsertMethod = `Insert(ctx context.Context, data *{{.upperStartCamelObject}}) (sql.Result,error)`
|
||||
|
||||
// pg
|
||||
var InsertMethodPg = `Insert(ctx context.Context, data *{{.upperStartCamelObject}}) (int64,error)`
|
||||
|
||||
Reference in New Issue
Block a user