-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfile.go.tmpl
More file actions
50 lines (42 loc) · 1.17 KB
/
file.go.tmpl
File metadata and controls
50 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// DO NOT EDIT THIS FILE!
// It is autogenerated by gentity
package {{ .PackageName }}
import (
"fmt"
"strings"
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
{{ range $alias, $import :=.Imports }}
{{ if eq $alias $import }}
"{{ $import }}"
{{ else }}
{{ $alias }} "{{ $import }}"
{{ end }}
{{ end }}
)
const chunkSize = 1000
type InsertOption struct {
ReturnAndUpdateVals bool
OnConflictStatement string
}
type DBExecutor interface {
Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
type DBExecutorKey string
func fromContext(ctx context.Context) DBExecutor {
dbExecutorVal := ctx.Value(DBExecutorKey("dbExecutor"))
if dbExecutorVal == nil {
dbExecutorVal = ctx.Value("dbExecutor")
}
dbe, ok := dbExecutorVal.(DBExecutor)
if !ok {
panic("DBExecutor not found in context")
}
return dbe
}
{{ range $entity := .Entities }}
{{ template "entity.go.tmpl" $entity }}
{{ end }}