mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
doc: add warning for Unwrap (#4217)
* entc: document Unwrap with panic, doc: add warning for Unwrap * resolve feedback
This commit is contained in:
@@ -60,6 +60,11 @@ func rollback(tx *ent.Tx, err error) error {
|
||||
|
||||
You must call `Unwrap()` if you are querying edges off of a created entity after a successful transaction (example: `a8m.QueryGroups()`). Unwrap restores the state of the underlying client embedded within the entity to a non-transactable version.
|
||||
|
||||
:::warning Note
|
||||
Calling `Unwrap()` on a non-transactional entity (i.e., after a transaction has been committed or rolled back) will
|
||||
cause a panic.
|
||||
:::
|
||||
|
||||
The full example exists in [GitHub](https://github.com/ent/ent/tree/master/examples/traversal).
|
||||
|
||||
## Transactional Client
|
||||
@@ -176,4 +181,4 @@ Some drivers support tweaking a transaction's isolation level. For example, with
|
||||
|
||||
```go
|
||||
tx, err := client.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelRepeatableRead})
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user