hook

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.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 AllMethodsServiceFunc added in v0.2.0

type AllMethodsServiceFunc func(context.Context, *ent.AllMethodsServiceMutation) (ent.Value, error)

The AllMethodsServiceFunc type is an adapter to allow the use of ordinary function as AllMethodsService mutator.

func (AllMethodsServiceFunc) Mutate added in v0.2.0

Mutate calls f(ctx, m).

type BlogPostFunc

type BlogPostFunc func(context.Context, *ent.BlogPostMutation) (ent.Value, error)

The BlogPostFunc type is an adapter to allow the use of ordinary function as BlogPost mutator.

func (BlogPostFunc) Mutate

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

Mutate calls f(ctx, m).

type CategoryFunc

type CategoryFunc func(context.Context, *ent.CategoryMutation) (ent.Value, error)

The CategoryFunc type is an adapter to allow the use of ordinary function as Category mutator.

func (CategoryFunc) Mutate

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

type DependsOnSkippedFunc func(context.Context, *ent.DependsOnSkippedMutation) (ent.Value, error)

The DependsOnSkippedFunc type is an adapter to allow the use of ordinary function as DependsOnSkipped mutator.

func (DependsOnSkippedFunc) Mutate

Mutate calls f(ctx, m).

type DuplicateNumberMessageFunc

type DuplicateNumberMessageFunc func(context.Context, *ent.DuplicateNumberMessageMutation) (ent.Value, error)

The DuplicateNumberMessageFunc type is an adapter to allow the use of ordinary function as DuplicateNumberMessage mutator.

func (DuplicateNumberMessageFunc) Mutate

Mutate calls f(ctx, m).

type EnumWithConflictingValueFunc added in v0.5.0

type EnumWithConflictingValueFunc func(context.Context, *ent.EnumWithConflictingValueMutation) (ent.Value, error)

The EnumWithConflictingValueFunc type is an adapter to allow the use of ordinary function as EnumWithConflictingValue mutator.

func (EnumWithConflictingValueFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type ExplicitSkippedMessageFunc

type ExplicitSkippedMessageFunc func(context.Context, *ent.ExplicitSkippedMessageMutation) (ent.Value, error)

The ExplicitSkippedMessageFunc type is an adapter to allow the use of ordinary function as ExplicitSkippedMessage mutator.

func (ExplicitSkippedMessageFunc) Mutate

Mutate calls f(ctx, m).

type ImageFunc

type ImageFunc func(context.Context, *ent.ImageMutation) (ent.Value, error)

The ImageFunc type is an adapter to allow the use of ordinary function as Image mutator.

func (ImageFunc) Mutate

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

Mutate calls f(ctx, m).

type ImplicitSkippedMessageFunc

type ImplicitSkippedMessageFunc func(context.Context, *ent.ImplicitSkippedMessageMutation) (ent.Value, error)

The ImplicitSkippedMessageFunc type is an adapter to allow the use of ordinary function as ImplicitSkippedMessage mutator.

func (ImplicitSkippedMessageFunc) Mutate

Mutate calls f(ctx, m).

type InvalidFieldMessageFunc

type InvalidFieldMessageFunc func(context.Context, *ent.InvalidFieldMessageMutation) (ent.Value, error)

The InvalidFieldMessageFunc type is an adapter to allow the use of ordinary function as InvalidFieldMessage mutator.

func (InvalidFieldMessageFunc) Mutate

Mutate calls f(ctx, m).

type MessageWithEnumFunc

type MessageWithEnumFunc func(context.Context, *ent.MessageWithEnumMutation) (ent.Value, error)

The MessageWithEnumFunc type is an adapter to allow the use of ordinary function as MessageWithEnum mutator.

func (MessageWithEnumFunc) Mutate

Mutate calls f(ctx, m).

type MessageWithFieldOneFunc

type MessageWithFieldOneFunc func(context.Context, *ent.MessageWithFieldOneMutation) (ent.Value, error)

The MessageWithFieldOneFunc type is an adapter to allow the use of ordinary function as MessageWithFieldOne mutator.

func (MessageWithFieldOneFunc) Mutate

Mutate calls f(ctx, m).

type MessageWithIDFunc

type MessageWithIDFunc func(context.Context, *ent.MessageWithIDMutation) (ent.Value, error)

The MessageWithIDFunc type is an adapter to allow the use of ordinary function as MessageWithID mutator.

func (MessageWithIDFunc) Mutate

Mutate calls f(ctx, m).

type MessageWithIntsFunc added in v0.5.0

type MessageWithIntsFunc func(context.Context, *ent.MessageWithIntsMutation) (ent.Value, error)

The MessageWithIntsFunc type is an adapter to allow the use of ordinary function as MessageWithInts mutator.

func (MessageWithIntsFunc) Mutate added in v0.5.0

Mutate calls f(ctx, m).

type MessageWithOptionalsFunc

type MessageWithOptionalsFunc func(context.Context, *ent.MessageWithOptionalsMutation) (ent.Value, error)

The MessageWithOptionalsFunc type is an adapter to allow the use of ordinary function as MessageWithOptionals mutator.

func (MessageWithOptionalsFunc) Mutate

Mutate calls f(ctx, m).

type MessageWithPackageNameFunc

type MessageWithPackageNameFunc func(context.Context, *ent.MessageWithPackageNameMutation) (ent.Value, error)

The MessageWithPackageNameFunc type is an adapter to allow the use of ordinary function as MessageWithPackageName mutator.

func (MessageWithPackageNameFunc) Mutate

Mutate calls f(ctx, m).

type MessageWithStringsFunc added in v0.3.0

type MessageWithStringsFunc func(context.Context, *ent.MessageWithStringsMutation) (ent.Value, error)

The MessageWithStringsFunc type is an adapter to allow the use of ordinary function as MessageWithStrings mutator.

func (MessageWithStringsFunc) Mutate added in v0.3.0

Mutate calls f(ctx, m).

type NoBackrefFunc added in v0.3.0

type NoBackrefFunc func(context.Context, *ent.NoBackrefMutation) (ent.Value, error)

The NoBackrefFunc type is an adapter to allow the use of ordinary function as NoBackref mutator.

func (NoBackrefFunc) Mutate added in v0.3.0

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

Mutate calls f(ctx, m).

type OneMethodServiceFunc added in v0.2.0

type OneMethodServiceFunc func(context.Context, *ent.OneMethodServiceMutation) (ent.Value, error)

The OneMethodServiceFunc type is an adapter to allow the use of ordinary function as OneMethodService mutator.

func (OneMethodServiceFunc) Mutate added in v0.2.0

Mutate calls f(ctx, m).

type PortalFunc

type PortalFunc func(context.Context, *ent.PortalMutation) (ent.Value, error)

The PortalFunc type is an adapter to allow the use of ordinary function as Portal mutator.

func (PortalFunc) Mutate

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

Mutate calls f(ctx, m).

type SkipEdgeExampleFunc added in v0.3.0

type SkipEdgeExampleFunc func(context.Context, *ent.SkipEdgeExampleMutation) (ent.Value, error)

The SkipEdgeExampleFunc type is an adapter to allow the use of ordinary function as SkipEdgeExample mutator.

func (SkipEdgeExampleFunc) Mutate added in v0.3.0

Mutate calls f(ctx, m).

type TwoMethodServiceFunc added in v0.2.0

type TwoMethodServiceFunc func(context.Context, *ent.TwoMethodServiceMutation) (ent.Value, error)

The TwoMethodServiceFunc type is an adapter to allow the use of ordinary function as TwoMethodService mutator.

func (TwoMethodServiceFunc) Mutate added in v0.2.0

Mutate calls f(ctx, m).

type UserFunc

type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)

The UserFunc type is an adapter to allow the use of ordinary function as User mutator.

func (UserFunc) Mutate

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

Mutate calls f(ctx, m).

type ValidMessageFunc

type ValidMessageFunc func(context.Context, *ent.ValidMessageMutation) (ent.Value, error)

The ValidMessageFunc type is an adapter to allow the use of ordinary function as ValidMessage mutator.

func (ValidMessageFunc) Mutate

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