hook

package
v0.10.0-rc14 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT 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 BuildTraceEntryFunc

type BuildTraceEntryFunc func(context.Context, *ent.BuildTraceEntryMutation) (ent.Value, error)

The BuildTraceEntryFunc type is an adapter to allow the use of ordinary function as BuildTraceEntry mutator.

func (BuildTraceEntryFunc) Mutate

Mutate calls f(ctx, m).

type BuildTraceSignatureFunc

type BuildTraceSignatureFunc func(context.Context, *ent.BuildTraceSignatureMutation) (ent.Value, error)

The BuildTraceSignatureFunc type is an adapter to allow the use of ordinary function as BuildTraceSignature mutator.

func (BuildTraceSignatureFunc) Mutate

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 ChunkFunc

type ChunkFunc func(context.Context, *ent.ChunkMutation) (ent.Value, error)

The ChunkFunc type is an adapter to allow the use of ordinary function as Chunk mutator.

func (ChunkFunc) Mutate

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

type ConfigEntryFunc func(context.Context, *ent.ConfigEntryMutation) (ent.Value, error)

The ConfigEntryFunc type is an adapter to allow the use of ordinary function as ConfigEntry mutator.

func (ConfigEntryFunc) Mutate

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

Mutate calls f(ctx, m).

type NarFileChunkFunc

type NarFileChunkFunc func(context.Context, *ent.NarFileChunkMutation) (ent.Value, error)

The NarFileChunkFunc type is an adapter to allow the use of ordinary function as NarFileChunk mutator.

func (NarFileChunkFunc) Mutate

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

Mutate calls f(ctx, m).

type NarFileFunc

type NarFileFunc func(context.Context, *ent.NarFileMutation) (ent.Value, error)

The NarFileFunc type is an adapter to allow the use of ordinary function as NarFile mutator.

func (NarFileFunc) Mutate

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

Mutate calls f(ctx, m).

type NarInfoFunc

type NarInfoFunc func(context.Context, *ent.NarInfoMutation) (ent.Value, error)

The NarInfoFunc type is an adapter to allow the use of ordinary function as NarInfo mutator.

func (NarInfoFunc) Mutate

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

Mutate calls f(ctx, m).

type NarInfoNarFileFunc

type NarInfoNarFileFunc func(context.Context, *ent.NarInfoNarFileMutation) (ent.Value, error)

The NarInfoNarFileFunc type is an adapter to allow the use of ordinary function as NarInfoNarFile mutator.

func (NarInfoNarFileFunc) Mutate

Mutate calls f(ctx, m).

type NarInfoReferenceFunc

type NarInfoReferenceFunc func(context.Context, *ent.NarInfoReferenceMutation) (ent.Value, error)

The NarInfoReferenceFunc type is an adapter to allow the use of ordinary function as NarInfoReference mutator.

func (NarInfoReferenceFunc) Mutate

Mutate calls f(ctx, m).

type NarInfoSignatureFunc

type NarInfoSignatureFunc func(context.Context, *ent.NarInfoSignatureMutation) (ent.Value, error)

The NarInfoSignatureFunc type is an adapter to allow the use of ordinary function as NarInfoSignature mutator.

func (NarInfoSignatureFunc) Mutate

Mutate calls f(ctx, m).

type PinnedClosureFunc

type PinnedClosureFunc func(context.Context, *ent.PinnedClosureMutation) (ent.Value, error)

The PinnedClosureFunc type is an adapter to allow the use of ordinary function as PinnedClosure mutator.

func (PinnedClosureFunc) Mutate

Mutate calls f(ctx, m).

type StagingStateFunc

type StagingStateFunc func(context.Context, *ent.StagingStateMutation) (ent.Value, error)

The StagingStateFunc type is an adapter to allow the use of ordinary function as StagingState mutator.

func (StagingStateFunc) Mutate

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