|
@@ -77,6 +77,10 @@ func (d *DBMethods) Each(ctx context.Context, query string, callback func(ctx co
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+func (d *DBMethods) EachPrepared(ctx context.Context, prep *Prepared, callback func(ctx context.Context, rows *Rows) error) error {
|
|
|
+ return d.Each(ctx, prep.Query, callback, prep.Args...)
|
|
|
+}
|
|
|
+
|
|
|
func (d *DBMethods) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
|
|
start := time.Now()
|
|
|
res, err := d.DB.ExecContext(ctx, d.fixQuery(query), args...)
|
|
@@ -84,6 +88,10 @@ func (d *DBMethods) Exec(ctx context.Context, query string, args ...any) (sql.Re
|
|
|
return res, err
|
|
|
}
|
|
|
|
|
|
+func (d *DBMethods) ExecPrepared(ctx context.Context, prep *Prepared) (sql.Result, error) {
|
|
|
+ return d.Exec(ctx, prep.Query, prep.Query)
|
|
|
+}
|
|
|
+
|
|
|
func (d *DBMethods) Ping(ctx context.Context) error {
|
|
|
start := time.Now()
|
|
|
err := d.DB.PingContext(ctx)
|
|
@@ -105,6 +113,10 @@ func (d *DBMethods) Query(ctx context.Context, query string, args ...any) (*Rows
|
|
|
return &Rows{Rows: rows}, err
|
|
|
}
|
|
|
|
|
|
+func (d *DBMethods) QueryPrepared(ctx context.Context, prep *Prepared) (*Rows, error) {
|
|
|
+ return d.Query(ctx, prep.Query, prep.Args...)
|
|
|
+}
|
|
|
+
|
|
|
func (d *DBMethods) QueryRow(ctx context.Context, query string, args ...any) *Row {
|
|
|
start := time.Now()
|
|
|
row := d.DB.QueryRowContext(ctx, d.fixQuery(query), args...)
|
|
@@ -117,6 +129,10 @@ func (d *DBMethods) QueryRowByID(ctx context.Context, id int64, row any) error {
|
|
|
return d.QueryRow(ctx, query, id).Scans(row)
|
|
|
}
|
|
|
|
|
|
+func (d *DBMethods) QueryRowPrepared(ctx context.Context, prep *Prepared) *Row {
|
|
|
+ return d.QueryRow(ctx, prep.Query, prep.Args...)
|
|
|
+}
|
|
|
+
|
|
|
func (d *DBMethods) RowExists(ctx context.Context, id int64, row any) bool {
|
|
|
var exists int
|
|
|
query := rowExistsString(row)
|