hook

package
v0.0.0-...-3befcbb Latest Latest
Warning

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

Go to latest
Published: Oct 19, 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 AmountFunc

type AmountFunc func(context.Context, *ent.AmountMutation) (ent.Value, error)

The AmountFunc type is an adapter to allow the use of ordinary function as Amount mutator.

func (AmountFunc) Mutate

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

Mutate calls f(ctx, m).

type BodyPartFunc

type BodyPartFunc func(context.Context, *ent.BodyPartMutation) (ent.Value, error)

The BodyPartFunc type is an adapter to allow the use of ordinary function as BodyPart mutator.

func (BodyPartFunc) Mutate

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

type DopeFunc func(context.Context, *ent.DopeMutation) (ent.Value, error)

The DopeFunc type is an adapter to allow the use of ordinary function as Dope mutator.

func (DopeFunc) Mutate

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

Mutate calls f(ctx, m).

type EventFunc

type EventFunc func(context.Context, *ent.EventMutation) (ent.Value, error)

The EventFunc type is an adapter to allow the use of ordinary function as Event mutator.

func (EventFunc) Mutate

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

Mutate calls f(ctx, m).

type GameHustlerFunc

type GameHustlerFunc func(context.Context, *ent.GameHustlerMutation) (ent.Value, error)

The GameHustlerFunc type is an adapter to allow the use of ordinary function as GameHustler mutator.

func (GameHustlerFunc) Mutate

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

Mutate calls f(ctx, m).

type GameHustlerItemFunc

type GameHustlerItemFunc func(context.Context, *ent.GameHustlerItemMutation) (ent.Value, error)

The GameHustlerItemFunc type is an adapter to allow the use of ordinary function as GameHustlerItem mutator.

func (GameHustlerItemFunc) Mutate

Mutate calls f(ctx, m).

type GameHustlerQuestFunc

type GameHustlerQuestFunc func(context.Context, *ent.GameHustlerQuestMutation) (ent.Value, error)

The GameHustlerQuestFunc type is an adapter to allow the use of ordinary function as GameHustlerQuest mutator.

func (GameHustlerQuestFunc) Mutate

Mutate calls f(ctx, m).

type GameHustlerRelationFunc

type GameHustlerRelationFunc func(context.Context, *ent.GameHustlerRelationMutation) (ent.Value, error)

The GameHustlerRelationFunc type is an adapter to allow the use of ordinary function as GameHustlerRelation mutator.

func (GameHustlerRelationFunc) Mutate

Mutate calls f(ctx, m).

type HustlerFunc

type HustlerFunc func(context.Context, *ent.HustlerMutation) (ent.Value, error)

The HustlerFunc type is an adapter to allow the use of ordinary function as Hustler mutator.

func (HustlerFunc) Mutate

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

Mutate calls f(ctx, m).

type ItemFunc

type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)

The ItemFunc type is an adapter to allow the use of ordinary function as Item mutator.

func (ItemFunc) Mutate

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

Mutate calls f(ctx, m).

type ListingFunc

type ListingFunc func(context.Context, *ent.ListingMutation) (ent.Value, error)

The ListingFunc type is an adapter to allow the use of ordinary function as Listing mutator.

func (ListingFunc) Mutate

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

Mutate calls f(ctx, m).

type SearchFunc

type SearchFunc func(context.Context, *ent.SearchMutation) (ent.Value, error)

The SearchFunc type is an adapter to allow the use of ordinary function as Search mutator.

func (SearchFunc) Mutate

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

Mutate calls f(ctx, m).

type SyncStateFunc

type SyncStateFunc func(context.Context, *ent.SyncStateMutation) (ent.Value, error)

The SyncStateFunc type is an adapter to allow the use of ordinary function as SyncState mutator.

func (SyncStateFunc) Mutate

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

Mutate calls f(ctx, m).

type WalletFunc

type WalletFunc func(context.Context, *ent.WalletMutation) (ent.Value, error)

The WalletFunc type is an adapter to allow the use of ordinary function as Wallet mutator.

func (WalletFunc) Mutate

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

Mutate calls f(ctx, m).

type WalletItemsFunc

type WalletItemsFunc func(context.Context, *ent.WalletItemsMutation) (ent.Value, error)

The WalletItemsFunc type is an adapter to allow the use of ordinary function as WalletItems mutator.

func (WalletItemsFunc) Mutate

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