hook

package
v0.0.0-...-4b256dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedError

func FixedError(err error) ent.Hook

FixedError is a hook returning a fixed error.

func If

func If(hk ent.Hook, cond Condition) ent.Hook

If executes the given hook under condition.

hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))

func On

func On(hk ent.Hook, op ent.Op) ent.Hook

On executes the given hook only for the given operation.

hook.On(Log, ent.Delete|ent.Create)

func Reject

func Reject(op ent.Op) ent.Hook

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

func Unless(hk ent.Hook, op ent.Op) ent.Hook

Unless skips the given hook only for the given operation.

hook.Unless(Log, ent.Update|ent.UpdateOne)

Types

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

func NewChain(hooks ...ent.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

func (c Chain) Append(hooks ...ent.Hook) Chain

Append extends a chain, adding the specified hook as the last ones in the mutation flow.

func (Chain) Extend

func (c Chain) Extend(chain Chain) Chain

Extend extends a chain, adding the specified chain as the last ones in the mutation flow.

func (Chain) Hook

func (c Chain) Hook() ent.Hook

Hook chains the list of hooks and returns the final hook.

type Condition

type Condition func(context.Context, ent.Mutation) bool

Condition is a hook condition function.

func And

func And(first, second Condition, rest ...Condition) Condition

And groups conditions with the AND operator.

func HasAddedFields

func HasAddedFields(field string, fields ...string) Condition

HasAddedFields is a condition validating `.AddedField` on fields.

func HasClearedFields

func HasClearedFields(field string, fields ...string) Condition

HasClearedFields is a condition validating `.FieldCleared` on fields.

func HasFields

func HasFields(field string, fields ...string) Condition

HasFields is a condition validating `.Field` on fields.

func HasOp

func HasOp(op ent.Op) Condition

HasOp is a condition testing mutation operation.

func Not

func Not(cond Condition) Condition

Not negates a given condition.

func Or

func Or(first, second Condition, rest ...Condition) Condition

Or groups conditions with the OR operator.

type MatchFunc

type MatchFunc func(context.Context, *ent.MatchMutation) (ent.Value, error)

The MatchFunc type is an adapter to allow the use of ordinary function as Match mutator.

func (MatchFunc) Mutate

func (f MatchFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type MatchPlayerFunc

type MatchPlayerFunc func(context.Context, *ent.MatchPlayerMutation) (ent.Value, error)

The MatchPlayerFunc type is an adapter to allow the use of ordinary function as MatchPlayer mutator.

func (MatchPlayerFunc) Mutate

func (f MatchPlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type MessagesFunc

type MessagesFunc func(context.Context, *ent.MessagesMutation) (ent.Value, error)

The MessagesFunc type is an adapter to allow the use of ordinary function as Messages mutator.

func (MessagesFunc) Mutate

func (f MessagesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type PlayerFunc

type PlayerFunc func(context.Context, *ent.PlayerMutation) (ent.Value, error)

The PlayerFunc type is an adapter to allow the use of ordinary function as Player mutator.

func (PlayerFunc) Mutate

func (f PlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type RoundStatsFunc

type RoundStatsFunc func(context.Context, *ent.RoundStatsMutation) (ent.Value, error)

The RoundStatsFunc type is an adapter to allow the use of ordinary function as RoundStats mutator.

func (RoundStatsFunc) Mutate

func (f RoundStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type SprayFunc

type SprayFunc func(context.Context, *ent.SprayMutation) (ent.Value, error)

The SprayFunc type is an adapter to allow the use of ordinary function as Spray mutator.

func (SprayFunc) Mutate

func (f SprayFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type WeaponFunc

type WeaponFunc func(context.Context, *ent.WeaponMutation) (ent.Value, error)

The WeaponFunc type is an adapter to allow the use of ordinary function as Weapon mutator.

func (WeaponFunc) Mutate

func (f WeaponFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL