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