hook

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: AGPL-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 AnalyticsEventFunc added in v1.35.0

type AnalyticsEventFunc func(context.Context, *ent.AnalyticsEventMutation) (ent.Value, error)

The AnalyticsEventFunc type is an adapter to allow the use of ordinary function as AnalyticsEvent mutator.

func (AnalyticsEventFunc) Mutate added in v1.35.0

Mutate calls f(ctx, m).

type ApprovalRuleFunc added in v1.12.0

type ApprovalRuleFunc func(context.Context, *ent.ApprovalRuleMutation) (ent.Value, error)

The ApprovalRuleFunc type is an adapter to allow the use of ordinary function as ApprovalRule mutator.

func (ApprovalRuleFunc) Mutate added in v1.12.0

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

Mutate calls f(ctx, m).

type BacklogItemDependencyFunc added in v1.43.0

type BacklogItemDependencyFunc func(context.Context, *ent.BacklogItemDependencyMutation) (ent.Value, error)

The BacklogItemDependencyFunc type is an adapter to allow the use of ordinary function as BacklogItemDependency mutator.

func (BacklogItemDependencyFunc) Mutate added in v1.43.0

Mutate calls f(ctx, m).

type BacklogItemFunc added in v1.35.0

type BacklogItemFunc func(context.Context, *ent.BacklogItemMutation) (ent.Value, error)

The BacklogItemFunc type is an adapter to allow the use of ordinary function as BacklogItem mutator.

func (BacklogItemFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type BacklogProgressNoteFunc added in v1.38.0

type BacklogProgressNoteFunc func(context.Context, *ent.BacklogProgressNoteMutation) (ent.Value, error)

The BacklogProgressNoteFunc type is an adapter to allow the use of ordinary function as BacklogProgressNote mutator.

func (BacklogProgressNoteFunc) Mutate added in v1.38.0

Mutate calls f(ctx, m).

type BacklogStatusEventFunc added in v1.35.0

type BacklogStatusEventFunc func(context.Context, *ent.BacklogStatusEventMutation) (ent.Value, error)

The BacklogStatusEventFunc type is an adapter to allow the use of ordinary function as BacklogStatusEvent mutator.

func (BacklogStatusEventFunc) Mutate added in v1.35.0

Mutate calls f(ctx, m).

type BacklogStuckStateFunc added in v1.38.0

type BacklogStuckStateFunc func(context.Context, *ent.BacklogStuckStateMutation) (ent.Value, error)

The BacklogStuckStateFunc type is an adapter to allow the use of ordinary function as BacklogStuckState mutator.

func (BacklogStuckStateFunc) Mutate added in v1.38.0

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 ClassificationAnalyticsFunc added in v1.12.0

type ClassificationAnalyticsFunc func(context.Context, *ent.ClassificationAnalyticsMutation) (ent.Value, error)

The ClassificationAnalyticsFunc type is an adapter to allow the use of ordinary function as ClassificationAnalytics mutator.

func (ClassificationAnalyticsFunc) Mutate added in v1.12.0

Mutate calls f(ctx, m).

type ClaudeMetadataFunc

type ClaudeMetadataFunc func(context.Context, *ent.ClaudeMetadataMutation) (ent.Value, error)

The ClaudeMetadataFunc type is an adapter to allow the use of ordinary function as ClaudeMetadata mutator.

func (ClaudeMetadataFunc) Mutate

Mutate calls f(ctx, m).

type ClaudeSessionFunc

type ClaudeSessionFunc func(context.Context, *ent.ClaudeSessionMutation) (ent.Value, error)

The ClaudeSessionFunc type is an adapter to allow the use of ordinary function as ClaudeSession mutator.

func (ClaudeSessionFunc) Mutate

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 DiffStatsFunc

type DiffStatsFunc func(context.Context, *ent.DiffStatsMutation) (ent.Value, error)

The DiffStatsFunc type is an adapter to allow the use of ordinary function as DiffStats mutator.

func (DiffStatsFunc) Mutate

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

Mutate calls f(ctx, m).

type ErrorEventFunc added in v1.35.0

type ErrorEventFunc func(context.Context, *ent.ErrorEventMutation) (ent.Value, error)

The ErrorEventFunc type is an adapter to allow the use of ordinary function as ErrorEvent mutator.

func (ErrorEventFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type EscapeEventFunc added in v1.35.0

type EscapeEventFunc func(context.Context, *ent.EscapeEventMutation) (ent.Value, error)

The EscapeEventFunc type is an adapter to allow the use of ordinary function as EscapeEvent mutator.

func (EscapeEventFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type ItemSessionFunc added in v1.35.0

type ItemSessionFunc func(context.Context, *ent.ItemSessionMutation) (ent.Value, error)

The ItemSessionFunc type is an adapter to allow the use of ordinary function as ItemSession mutator.

func (ItemSessionFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type ItemSourceFunc added in v1.35.0

type ItemSourceFunc func(context.Context, *ent.ItemSourceMutation) (ent.Value, error)

The ItemSourceFunc type is an adapter to allow the use of ordinary function as ItemSource mutator.

func (ItemSourceFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type PipelineModeFunc added in v1.38.0

type PipelineModeFunc func(context.Context, *ent.PipelineModeMutation) (ent.Value, error)

The PipelineModeFunc type is an adapter to allow the use of ordinary function as PipelineMode mutator.

func (PipelineModeFunc) Mutate added in v1.38.0

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

Mutate calls f(ctx, m).

type ProjectFunc added in v1.23.0

type ProjectFunc func(context.Context, *ent.ProjectMutation) (ent.Value, error)

The ProjectFunc type is an adapter to allow the use of ordinary function as Project mutator.

func (ProjectFunc) Mutate added in v1.23.0

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

Mutate calls f(ctx, m).

type ReviewVerdictFunc added in v1.35.0

type ReviewVerdictFunc func(context.Context, *ent.ReviewVerdictMutation) (ent.Value, error)

The ReviewVerdictFunc type is an adapter to allow the use of ordinary function as ReviewVerdict mutator.

func (ReviewVerdictFunc) Mutate added in v1.35.0

Mutate calls f(ctx, m).

type SessionFunc

type SessionFunc func(context.Context, *ent.SessionMutation) (ent.Value, error)

The SessionFunc type is an adapter to allow the use of ordinary function as Session mutator.

func (SessionFunc) Mutate

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

Mutate calls f(ctx, m).

type SessionGoalFunc added in v1.35.0

type SessionGoalFunc func(context.Context, *ent.SessionGoalMutation) (ent.Value, error)

The SessionGoalFunc type is an adapter to allow the use of ordinary function as SessionGoal mutator.

func (SessionGoalFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type SessionSummaryFunc added in v1.41.0

type SessionSummaryFunc func(context.Context, *ent.SessionSummaryMutation) (ent.Value, error)

The SessionSummaryFunc type is an adapter to allow the use of ordinary function as SessionSummary mutator.

func (SessionSummaryFunc) Mutate added in v1.41.0

Mutate calls f(ctx, m).

type ShellFunc added in v1.35.0

type ShellFunc func(context.Context, *ent.ShellMutation) (ent.Value, error)

The ShellFunc type is an adapter to allow the use of ordinary function as Shell mutator.

func (ShellFunc) Mutate added in v1.35.0

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

Mutate calls f(ctx, m).

type SourceSyncEventFunc added in v1.35.0

type SourceSyncEventFunc func(context.Context, *ent.SourceSyncEventMutation) (ent.Value, error)

The SourceSyncEventFunc type is an adapter to allow the use of ordinary function as SourceSyncEvent mutator.

func (SourceSyncEventFunc) Mutate added in v1.35.0

Mutate calls f(ctx, m).

type TagFunc

type TagFunc func(context.Context, *ent.TagMutation) (ent.Value, error)

The TagFunc type is an adapter to allow the use of ordinary function as Tag mutator.

func (TagFunc) Mutate

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

Mutate calls f(ctx, m).

type TriggerFireEventFunc added in v1.43.0

type TriggerFireEventFunc func(context.Context, *ent.TriggerFireEventMutation) (ent.Value, error)

The TriggerFireEventFunc type is an adapter to allow the use of ordinary function as TriggerFireEvent mutator.

func (TriggerFireEventFunc) Mutate added in v1.43.0

Mutate calls f(ctx, m).

type WorkflowFunc added in v1.35.0

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 added in v1.35.0

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

Mutate calls f(ctx, m).

type WorktreeFunc

type WorktreeFunc func(context.Context, *ent.WorktreeMutation) (ent.Value, error)

The WorktreeFunc type is an adapter to allow the use of ordinary function as Worktree mutator.

func (WorktreeFunc) Mutate

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