hook

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 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 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 CloudEventsFunc

type CloudEventsFunc func(context.Context, *ent.CloudEventsMutation) (ent.Value, error)

The CloudEventsFunc type is an adapter to allow the use of ordinary function as CloudEvents mutator.

func (CloudEventsFunc) Mutate

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

Mutate calls f(ctx, m).

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 EventsFunc

type EventsFunc func(context.Context, *ent.EventsMutation) (ent.Value, error)

The EventsFunc type is an adapter to allow the use of ordinary function as Events mutator.

func (EventsFunc) Mutate

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

Mutate calls f(ctx, m).

type EventsWaitFunc

type EventsWaitFunc func(context.Context, *ent.EventsWaitMutation) (ent.Value, error)

The EventsWaitFunc type is an adapter to allow the use of ordinary function as EventsWait mutator.

func (EventsWaitFunc) Mutate

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

Mutate calls f(ctx, m).

type InodeFunc

type InodeFunc func(context.Context, *ent.InodeMutation) (ent.Value, error)

The InodeFunc type is an adapter to allow the use of ordinary function as Inode mutator.

func (InodeFunc) Mutate

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

Mutate calls f(ctx, m).

type InstanceFunc

type InstanceFunc func(context.Context, *ent.InstanceMutation) (ent.Value, error)

The InstanceFunc type is an adapter to allow the use of ordinary function as Instance mutator.

func (InstanceFunc) Mutate

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

Mutate calls f(ctx, m).

type InstanceRuntimeFunc

type InstanceRuntimeFunc func(context.Context, *ent.InstanceRuntimeMutation) (ent.Value, error)

The InstanceRuntimeFunc type is an adapter to allow the use of ordinary function as InstanceRuntime mutator.

func (InstanceRuntimeFunc) Mutate

Mutate calls f(ctx, m).

type LogMsgFunc

type LogMsgFunc func(context.Context, *ent.LogMsgMutation) (ent.Value, error)

The LogMsgFunc type is an adapter to allow the use of ordinary function as LogMsg mutator.

func (LogMsgFunc) Mutate

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

Mutate calls f(ctx, m).

type NamespaceFunc

type NamespaceFunc func(context.Context, *ent.NamespaceMutation) (ent.Value, error)

The NamespaceFunc type is an adapter to allow the use of ordinary function as Namespace mutator.

func (NamespaceFunc) Mutate

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

Mutate calls f(ctx, m).

type RefFunc

type RefFunc func(context.Context, *ent.RefMutation) (ent.Value, error)

The RefFunc type is an adapter to allow the use of ordinary function as Ref mutator.

func (RefFunc) Mutate

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

Mutate calls f(ctx, m).

type RevisionFunc

type RevisionFunc func(context.Context, *ent.RevisionMutation) (ent.Value, error)

The RevisionFunc type is an adapter to allow the use of ordinary function as Revision mutator.

func (RevisionFunc) Mutate

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

Mutate calls f(ctx, m).

type RouteFunc

type RouteFunc func(context.Context, *ent.RouteMutation) (ent.Value, error)

The RouteFunc type is an adapter to allow the use of ordinary function as Route mutator.

func (RouteFunc) Mutate

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

Mutate calls f(ctx, m).

type VarDataFunc

type VarDataFunc func(context.Context, *ent.VarDataMutation) (ent.Value, error)

The VarDataFunc type is an adapter to allow the use of ordinary function as VarData mutator.

func (VarDataFunc) Mutate

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

Mutate calls f(ctx, m).

type VarRefFunc

type VarRefFunc func(context.Context, *ent.VarRefMutation) (ent.Value, error)

The VarRefFunc type is an adapter to allow the use of ordinary function as VarRef mutator.

func (VarRefFunc) Mutate

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

Mutate calls f(ctx, m).

type WorkflowFunc

type WorkflowFunc func(context.Context, *ent.WorkflowMutation) (ent.Value, error)

The WorkflowFunc type is an adapter to allow the use of ordinary function as Workflow mutator.

func (WorkflowFunc) Mutate

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