add purchasing in analytics endpoint
This commit is contained in:
@@ -28,6 +28,10 @@ func NewTxManager(db *gorm.DB) *TxManager { return &TxManager{db: db} }
|
||||
|
||||
// WithTransaction runs fn inside a DB transaction, injecting the *gorm.DB tx into ctx.
|
||||
func (m *TxManager) WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error {
|
||||
if m == nil || m.db == nil {
|
||||
return fn(ctx)
|
||||
}
|
||||
|
||||
return m.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
ctxTx := context.WithValue(ctx, txKey, tx)
|
||||
return fn(ctxTx)
|
||||
|
||||
Reference in New Issue
Block a user