package hook
import "git.dotya.ml/mirre-mt/pcmt/ent/hook"
Index ¶
- func FixedError(err error) ent.Hook
- func If(hk ent.Hook, cond Condition) ent.Hook
- func On(hk ent.Hook, op ent.Op) ent.Hook
- func Reject(op ent.Op) ent.Hook
- func Unless(hk ent.Hook, op ent.Op) ent.Hook
- type AgeKeyFunc
- type Chain
- func NewChain(hooks ...ent.Hook) Chain
- func (c Chain) Append(hooks ...ent.Hook) Chain
- func (c Chain) Extend(chain Chain) Chain
- func (c Chain) Hook() ent.Hook
- type Condition
- func And(first, second Condition, rest ...Condition) Condition
- func HasAddedFields(field string, fields ...string) Condition
- func HasClearedFields(field string, fields ...string) Condition
- func HasFields(field string, fields ...string) Condition
- func HasOp(op ent.Op) Condition
- func Not(cond Condition) Condition
- func Or(first, second Condition, rest ...Condition) Condition
- type HIBPFunc
- type LocalBreachFunc
- type SearchQueryFunc
- type SettingsFunc
- type SetupFunc
- type TrackedBreachesFunc
- type UserFunc
Functions ¶
func FixedError ¶
FixedError is a hook returning a fixed error.
func If ¶
If executes the given hook under condition.
hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
func On ¶
On executes the given hook only for the given operation.
hook.On(Log, ent.Delete|ent.Create)
func Reject ¶
Reject returns a hook that rejects all operations that match op.
func (T) Hooks() []ent.Hook { return []ent.Hook{ Reject(ent.Delete|ent.Update), } }
func Unless ¶
Unless skips the given hook only for the given operation.
hook.Unless(Log, ent.Update|ent.UpdateOne)
Types ¶
type AgeKeyFunc ¶
The AgeKeyFunc type is an adapter to allow the use of ordinary function as AgeKey mutator.
func (AgeKeyFunc) Mutate ¶
Mutate calls f(ctx, m).
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain acts as a list of hooks and is effectively immutable. Once created, it will always hold the same set of hooks in the same order.
func NewChain ¶
NewChain creates a new chain of hooks.
func (Chain) Append ¶
Append extends a chain, adding the specified hook as the last ones in the mutation flow.
func (Chain) Extend ¶
Extend extends a chain, adding the specified chain as the last ones in the mutation flow.
func (Chain) Hook ¶
Hook chains the list of hooks and returns the final hook.
type Condition ¶
Condition is a hook condition function.
func And ¶
And groups conditions with the AND operator.
func HasAddedFields ¶
HasAddedFields is a condition validating `.AddedField` on fields.
func HasClearedFields ¶
HasClearedFields is a condition validating `.FieldCleared` on fields.
func HasFields ¶
HasFields is a condition validating `.Field` on fields.
func HasOp ¶
HasOp is a condition testing mutation operation.
func Not ¶
Not negates a given condition.
func Or ¶
Or groups conditions with the OR operator.
type HIBPFunc ¶
The HIBPFunc type is an adapter to allow the use of ordinary function as HIBP mutator.
func (HIBPFunc) Mutate ¶
Mutate calls f(ctx, m).
type LocalBreachFunc ¶
The LocalBreachFunc type is an adapter to allow the use of ordinary function as LocalBreach mutator.
func (LocalBreachFunc) Mutate ¶
Mutate calls f(ctx, m).
type SearchQueryFunc ¶
The SearchQueryFunc type is an adapter to allow the use of ordinary function as SearchQuery mutator.
func (SearchQueryFunc) Mutate ¶
Mutate calls f(ctx, m).
type SettingsFunc ¶
The SettingsFunc type is an adapter to allow the use of ordinary function as Settings mutator.
func (SettingsFunc) Mutate ¶
Mutate calls f(ctx, m).
type SetupFunc ¶
The SetupFunc type is an adapter to allow the use of ordinary function as Setup mutator.
func (SetupFunc) Mutate ¶
Mutate calls f(ctx, m).
type TrackedBreachesFunc ¶
The TrackedBreachesFunc type is an adapter to allow the use of ordinary function as TrackedBreaches mutator.
func (TrackedBreachesFunc) Mutate ¶
Mutate calls f(ctx, m).
type UserFunc ¶
The UserFunc type is an adapter to allow the use of ordinary function as User mutator.
func (UserFunc) Mutate ¶
Mutate calls f(ctx, m).
Source Files ¶
hook.go
- Version
- v0.0.0-20230910121657-4d10510f5ba4 (latest)
- Published
- Sep 10, 2023
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 1 month ago –
Tools for package owners.