Enha: create tx; cardword test
This commit is contained in:
@ -17,6 +17,7 @@ type AllRepos interface {
|
||||
PlayersRepo
|
||||
SessionsRepo
|
||||
WordCardsRepo
|
||||
InitTx(ctx context.Context) (context.Context, *sqlx.Tx, error)
|
||||
}
|
||||
|
||||
type RepoProvider struct {
|
||||
@ -95,3 +96,11 @@ func getDB(ctx context.Context, db *sqlx.DB) sqlx.ExtContext {
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func (p *RepoProvider) InitTx(ctx context.Context) (context.Context, *sqlx.Tx, error) {
|
||||
tx, err := p.DB.BeginTxx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return context.WithValue(ctx, "tx", tx), tx, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user