Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6788b76bfc |
18
gen.go.tmpl
18
gen.go.tmpl
@@ -5,7 +5,7 @@ import (
|
||||
"iter"
|
||||
)
|
||||
|
||||
type TX interface {
|
||||
type dbConn interface {
|
||||
Exec(query string, args ...any) (sql.Result, error)
|
||||
Query(query string, args ...any) (*sql.Rows, error)
|
||||
QueryRow(query string, args ...any) *sql.Row
|
||||
@@ -27,7 +27,7 @@ const {{.LowerType}}_SelectQuery = "{{.SelectQuery}}"
|
||||
{{if not .NoInsert -}}
|
||||
|
||||
func {{.LowerType}}_Insert(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
row *{{.Type}},
|
||||
) (err error) {
|
||||
{{.LowerType}}_Sanitize(row)
|
||||
@@ -46,7 +46,7 @@ func {{.LowerType}}_Insert(
|
||||
{{if .UpdateCols -}}
|
||||
|
||||
func {{.LowerType}}_Update(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
row *{{.Type}},
|
||||
) (err error) {
|
||||
{{.LowerType}}_Sanitize(row)
|
||||
@@ -77,7 +77,7 @@ func {{.LowerType}}_Update(
|
||||
{{if .UpdateFullCols -}}
|
||||
|
||||
func {{.LowerType}}_UpdateFull(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
row *{{.Type}},
|
||||
) (err error) {
|
||||
{{.LowerType}}_Sanitize(row)
|
||||
@@ -111,7 +111,7 @@ func {{.LowerType}}_UpdateFull(
|
||||
{{if not .NoDelete -}}
|
||||
|
||||
func {{.LowerType}}_Delete(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
{{.PKFunctionArgs -}}
|
||||
) (err error) {
|
||||
result, err := tx.Exec("{{.DeleteQuery}}", {{.DeleteArgs}})
|
||||
@@ -136,7 +136,7 @@ func {{.LowerType}}_Delete(
|
||||
{{- end}}
|
||||
|
||||
func {{.LowerType}}_Get(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
{{.PKFunctionArgs -}}
|
||||
) (
|
||||
row {{.Type}},
|
||||
@@ -148,7 +148,7 @@ func {{.LowerType}}_Get(
|
||||
}
|
||||
|
||||
func {{.LowerType}}_GetWhere(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
query string,
|
||||
args ...any,
|
||||
) (
|
||||
@@ -161,7 +161,7 @@ func {{.LowerType}}_GetWhere(
|
||||
}
|
||||
|
||||
func {{.LowerType}}_Iterate(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
query string,
|
||||
args ...any,
|
||||
) (
|
||||
@@ -190,7 +190,7 @@ func {{.LowerType}}_Iterate(
|
||||
}
|
||||
|
||||
func {{.LowerType}}_List(
|
||||
tx TX,
|
||||
tx dbConn,
|
||||
query string,
|
||||
args ...any,
|
||||
) (
|
||||
|
||||
Reference in New Issue
Block a user