// Tx returns a new transactional client. The provided context
// is used until the transaction is committed or rolled back.
Tx returns a new transactional client. The provided context
is used until the transaction is committed or rolled back.
// Tx returns a new transactional client . The provided context // is used until the transaction is committed or rolled back .
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
	if _, ok := c.driver.(*txDriver); ok {
		return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
	}
	tx, err := newTx(ctx, c.driver)
	if err != nil {
		return nil, fmt.Errorf("ent: starting a transaction: %w", err)
	}
	cfg := c.config
	cfg.driver = tx
	return &Tx{
		ctx:      ctx,
		config:   cfg,
		APIAudit: NewAPIAuditClient(cfg),
		Fact:     NewFactClient(cfg),
		FactType: NewFactTypeClient(cfg),
		Grant:    NewGrantClient(cfg),
		Scope:    NewScopeClient(cfg),
	}, nil
}
func ( c * Client ) Tx ( ctx context . Context ) ( * Tx , error ) { if _ , ok := c . driver . ( * txDriver ) ; ok { return nil , fmt . Errorf ( " " ) } tx , err := newTx ( ctx , c . driver ) if err != nil { return nil , fmt . Errorf ( " " , err ) } cfg := c . config cfg . driver = tx return & Tx { ctx : ctx , config : cfg , APIAudit : NewAPIAuditClient ( cfg ) , Fact : NewFactClient ( cfg ) , FactType : NewFactTypeClient ( cfg ) , Grant : NewGrantClient ( cfg ) , Scope : NewScopeClient ( cfg ) , } , nil }
Tx returns a new transactional client.
Tx returns a new transactional client .