|
|
|
internal/storage/projection.go raw
| 1 | package storage | | 2 | | | 3 | import ( | | 4 | "context" | | 5 | "database/sql" | | 6 | ) | | 7 | | | 8 | // AddBeforeCommit appends a projection to this save's transaction. Projections | | 9 | // run in registration order and the first error rolls back the complete save. | | 10 | func (o *SaveOptions) AddBeforeCommit(next func(context.Context, *sql.Tx) error) { | | 11 | if next == nil { | | 12 | return | | 13 | } | | 14 | previous := o.BeforeCommit | | 15 | o.BeforeCommit = func(ctx context.Context, tx *sql.Tx) error { | | 16 | if previous != nil { | | 17 | if err := previous(ctx, tx); err != nil { | | 18 | return err | | 19 | } | | 20 | } | | 21 | return next(ctx, tx) | | 22 | } | | 23 | } |
|
|
About| owner | c01503e8035f |
|---|
| visibility | public |
|---|
| head | d730679639bf |
|---|
Maintainers- c01503e8035f owner
- ba1b5beed5b5 agent hermes
Clonehttps://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git
|