Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
()
| 6475 | // Tx returns an `ent.Tx` for mutations that were executed in transactions; |
| 6476 | // it returns an error otherwise. |
| 6477 | func (m MetadataMutation) Tx() (*Tx, error) { |
| 6478 | if _, ok := m.driver.(*txDriver); !ok { |
| 6479 | return nil, errors.New("ent: mutation is not running in a transaction") |
| 6480 | } |
| 6481 | tx := &Tx{config: m.config} |
| 6482 | tx.init() |
| 6483 | return tx, nil |
| 6484 | } |
| 6485 | |
| 6486 | // ID returns the ID value in the mutation. Note that the ID is only available |
| 6487 | // if it was provided to the builder or after it was returned from the database. |