hook

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func On

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

On executes the given hook only of 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),
	}
}

Types

type ApplicationFunc

type ApplicationFunc func(context.Context, *ent.ApplicationMutation) (ent.Value, error)

The ApplicationFunc type is an adapter to allow the use of ordinary function as Application mutator.

func (ApplicationFunc) Mutate

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

type CounterFunc func(context.Context, *ent.CounterMutation) (ent.Value, error)

The CounterFunc type is an adapter to allow the use of ordinary function as Counter mutator.

func (CounterFunc) Mutate

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

Mutate calls f(ctx, m).

type GaugeFunc

type GaugeFunc func(context.Context, *ent.GaugeMutation) (ent.Value, error)

The GaugeFunc type is an adapter to allow the use of ordinary function as Gauge mutator.

func (GaugeFunc) Mutate

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

Mutate calls f(ctx, m).

type GraphFunc

type GraphFunc func(context.Context, *ent.GraphMutation) (ent.Value, error)

The GraphFunc type is an adapter to allow the use of ordinary function as Graph mutator.

func (GraphFunc) Mutate

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

Mutate calls f(ctx, m).

type GroupFunc

type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)

The GroupFunc type is an adapter to allow the use of ordinary function as Group mutator.

func (GroupFunc) Mutate

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

Mutate calls f(ctx, m).

type HistogramFunc

type HistogramFunc func(context.Context, *ent.HistogramMutation) (ent.Value, error)

The HistogramFunc type is an adapter to allow the use of ordinary function as Histogram mutator.

func (HistogramFunc) Mutate

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

Mutate calls f(ctx, m).

type MetricFunc

type MetricFunc func(context.Context, *ent.MetricMutation) (ent.Value, error)

The MetricFunc type is an adapter to allow the use of ordinary function as Metric mutator.

func (MetricFunc) Mutate

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