File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
internal/codegen/golang/templates/pgx Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 11{{define " dbCodeTemplatePgx" }}
22
33type DBTX interface {
4+ Begin(context.Context ) (pgx.Tx , error)
5+ BeginTx(context.Context , txOptions TxOptions) (pgx.Tx , error)
46 Exec(context.Context , string, ...interface {}) (pgconn.CommandTag , error)
57 Query(context.Context , string, ...interface {}) (pgx.Rows , error)
68 QueryRow(context.Context , string, ...interface {}) pgx.Row
@@ -33,5 +35,19 @@ func (q *Queries) WithTx(tx pgx.Tx) *Queries {
3335 db: tx,
3436 }
3537}
38+ func (q *Queries) Begin(ctx context.Context ) (*Queries, error) {
39+ tx, err := q.db.Begin (ctx)
40+ if (err != nil {
41+ return nil , err
42+ }
43+ return q.WithTx (tx), nil
44+ }
45+ func (q *Queries) BeginTx(ctx context.Context , txOptions TxOptions) (*Queries, error) {
46+ tx, err := q.db.BeginTx (ctx, txOptions)
47+ if (err != nil {
48+ return nil , err
49+ }
50+ return q.WithTx (tx), nil
51+ }
3652{{end }}
3753{{end }}
You can’t perform that action at this time.
0 commit comments