hook

package
v0.0.0-...-214d0a7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 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 CardFunc

type CardFunc func(context.Context, *ent.CardMutation) (ent.Value, error)

The CardFunc type is an adapter to allow the use of ordinary function as Card mutator.

func (CardFunc) Mutate

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

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

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 GameFunc

type GameFunc func(context.Context, *ent.GameMutation) (ent.Value, error)

The GameFunc type is an adapter to allow the use of ordinary function as Game mutator.

func (GameFunc) Mutate

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

Mutate calls f(ctx, m).

type GameUserFunc

type GameUserFunc func(context.Context, *ent.GameUserMutation) (ent.Value, error)

The GameUserFunc type is an adapter to allow the use of ordinary function as GameUser mutator.

func (GameUserFunc) Mutate

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

Mutate calls f(ctx, m).

type MissionFunc

type MissionFunc func(context.Context, *ent.MissionMutation) (ent.Value, error)

The MissionFunc type is an adapter to allow the use of ordinary function as Mission mutator.

func (MissionFunc) Mutate

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

Mutate calls f(ctx, m).

type RecordFunc

type RecordFunc func(context.Context, *ent.RecordMutation) (ent.Value, error)

The RecordFunc type is an adapter to allow the use of ordinary function as Record mutator.

func (RecordFunc) Mutate

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

Mutate calls f(ctx, m).

type RoomFunc

type RoomFunc func(context.Context, *ent.RoomMutation) (ent.Value, error)

The RoomFunc type is an adapter to allow the use of ordinary function as Room mutator.

func (RoomFunc) Mutate

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

Mutate calls f(ctx, m).

type RoomUserFunc

type RoomUserFunc func(context.Context, *ent.RoomUserMutation) (ent.Value, error)

The RoomUserFunc type is an adapter to allow the use of ordinary function as RoomUser mutator.

func (RoomUserFunc) Mutate

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

Mutate calls f(ctx, m).

type SquadFunc

type SquadFunc func(context.Context, *ent.SquadMutation) (ent.Value, error)

The SquadFunc type is an adapter to allow the use of ordinary function as Squad mutator.

func (SquadFunc) Mutate

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

Mutate calls f(ctx, m).

type VoteFunc

type VoteFunc func(context.Context, *ent.VoteMutation) (ent.Value, error)

The VoteFunc type is an adapter to allow the use of ordinary function as Vote mutator.

func (VoteFunc) Mutate

func (f VoteFunc) 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