All checks were successful
ci/woodpecker/push/build Pipeline was successful
Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
23 lines
400 B
Go
23 lines
400 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
func StartTransaction(ctx context.Context, db *sql.DB) (*sql.Tx, error) {
|
|
tx, err := db.BeginTx(ctx, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return tx, nil
|
|
}
|
|
|
|
func CommitTransaction(ctx context.Context, tx *sql.Tx) error {
|
|
return tx.Commit()
|
|
}
|
|
|
|
func RollBackTransaction(ctx context.Context, tx *sql.Tx) error {
|
|
return tx.Rollback()
|
|
}
|