Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
()
| 159 | // Tx returns an `ent.Tx` for mutations that were executed in transactions; |
| 160 | // it returns an error otherwise. |
| 161 | func (m APITokenMutation) Tx() (*Tx, error) { |
| 162 | if _, ok := m.driver.(*txDriver); !ok { |
| 163 | return nil, errors.New("ent: mutation is not running in a transaction") |
| 164 | } |
| 165 | tx := &Tx{config: m.config} |
| 166 | tx.init() |
| 167 | return tx, nil |
| 168 | } |
| 169 | |
| 170 | // SetID sets the value of the id field. Note that this |
| 171 | // operation is only accepted on creation of APIToken entities. |