Documentation
¶
Index ¶
- func Count(ctx context.Context, db *sql.DB, query string, args ...any) (int64, error)
- func Delete(ctx context.Context, db *sql.DB, query string, args ...any) (int64, error)
- func Insert(ctx context.Context, db *sql.DB, query string, args ...any) (int64, error)
- func InsertTx(ctx context.Context, db *sql.DB, query string, args ...any) (int64, error)
- func Row[T any](ctx context.Context, db *sql.DB, query string, args ...any) (T, error)
- func Rows[T any](ctx context.Context, db *sql.DB, query string, args ...any) ([]T, error)
- func Tx(ctx context.Context, db *sql.DB, ...) error
- func Update(ctx context.Context, db *sql.DB, query string, args ...any) (int64, error)
- func UpdateTx(ctx context.Context, db *sql.DB, query string, args ...any) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶ added in v0.7.0
Count is a helper function that wraps sql rows to scan into a single int. The query should return a single column with interger type such as count,sum etc. with a single row.
func InsertTx ¶ added in v0.7.0
InsertTx is a helper function that wraps sql exec to insert a row in a transaction.
func Row ¶
Row is a helper function that wraps sql rows to scan into a single struct. Row scans structs based on their db tag, and scan any fields not tagged with the db tag matched column name, So had better to tag all fields with db tag to avoid unexpected behavior.
func Rows ¶
Rows is a helper function that wraps sql rows to scan into a slice. Rows scans structs based on their db tag, and scan any fields not tagged with the db tag matched column name, So had better to tag all fields with db tag to avoid unexpected behavior.
Types ¶
This section is empty.