// BeginTx returns a transactional client with specified options.
BeginTx returns a transactional client with specified options.
// BeginTx returns a transactional client with specified options .
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
	if _, ok := c.driver.(*txDriver); ok {
		return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
	}
	tx, err := c.driver.(interface {
		BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
	}).BeginTx(ctx, opts)
	if err != nil {
		return nil, fmt.Errorf("ent: starting a transaction: %w", err)
	}
	cfg := c.config
	cfg.driver = &txDriver{tx: tx, drv: c.driver}
	return &Tx{
		config:   cfg,
		APIAudit: NewAPIAuditClient(cfg),
		Fact:     NewFactClient(cfg),
		FactType: NewFactTypeClient(cfg),
		Grant:    NewGrantClient(cfg),
		Scope:    NewScopeClient(cfg),
	}, nil
}
func ( c * Client ) BeginTx ( ctx context . Context , opts * sql . TxOptions ) ( * Tx , error ) { if _ , ok := c . driver . ( * txDriver ) ; ok { return nil , fmt . Errorf ( " " ) } tx , err := c . driver . ( interface { BeginTx ( context . Context , * sql . TxOptions ) ( dialect . Tx , error ) } ) . BeginTx ( ctx , opts ) if err != nil { return nil , fmt . Errorf ( " " , err ) } cfg := c . config cfg . driver = & txDriver { tx : tx , drv : c . driver } return & Tx { config : cfg , APIAudit : NewAPIAuditClient ( cfg ) , Fact : NewFactClient ( cfg ) , FactType : NewFactTypeClient ( cfg ) , Grant : NewGrantClient ( cfg ) , Scope : NewScopeClient ( cfg ) , } , nil }
BeginTx returns a transactional client with specified options.
BeginTx returns a transactional client with specified options .