hook

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 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 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 CustomFieldDefFunc

type CustomFieldDefFunc func(context.Context, *ent.CustomFieldDefMutation) (ent.Value, error)

The CustomFieldDefFunc type is an adapter to allow the use of ordinary function as CustomFieldDef mutator.

func (CustomFieldDefFunc) Mutate

Mutate calls f(ctx, m).

type DimensionOptionFunc

type DimensionOptionFunc func(context.Context, *ent.DimensionOptionMutation) (ent.Value, error)

The DimensionOptionFunc type is an adapter to allow the use of ordinary function as DimensionOption mutator.

func (DimensionOptionFunc) Mutate

Mutate calls f(ctx, m).

type EvidenceFunc

type EvidenceFunc func(context.Context, *ent.EvidenceMutation) (ent.Value, error)

The EvidenceFunc type is an adapter to allow the use of ordinary function as Evidence mutator.

func (EvidenceFunc) Mutate

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

Mutate calls f(ctx, m).

type ItemAugmentFunc

type ItemAugmentFunc func(context.Context, *ent.ItemAugmentMutation) (ent.Value, error)

The ItemAugmentFunc type is an adapter to allow the use of ordinary function as ItemAugment mutator.

func (ItemAugmentFunc) Mutate

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

Mutate calls f(ctx, m).

type ItemFunc

type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)

The ItemFunc type is an adapter to allow the use of ordinary function as Item mutator.

func (ItemFunc) Mutate

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

Mutate calls f(ctx, m).

type OpportunityAssessmentFunc

type OpportunityAssessmentFunc func(context.Context, *ent.OpportunityAssessmentMutation) (ent.Value, error)

The OpportunityAssessmentFunc type is an adapter to allow the use of ordinary function as OpportunityAssessment mutator.

func (OpportunityAssessmentFunc) Mutate

Mutate calls f(ctx, m).

type OpportunitySpecFunc

type OpportunitySpecFunc func(context.Context, *ent.OpportunitySpecMutation) (ent.Value, error)

The OpportunitySpecFunc type is an adapter to allow the use of ordinary function as OpportunitySpec mutator.

func (OpportunitySpecFunc) Mutate

Mutate calls f(ctx, m).

type PortfolioDimensionFunc

type PortfolioDimensionFunc func(context.Context, *ent.PortfolioDimensionMutation) (ent.Value, error)

The PortfolioDimensionFunc type is an adapter to allow the use of ordinary function as PortfolioDimension mutator.

func (PortfolioDimensionFunc) Mutate

Mutate calls f(ctx, m).

type ProfileAssignmentFunc

type ProfileAssignmentFunc func(context.Context, *ent.ProfileAssignmentMutation) (ent.Value, error)

The ProfileAssignmentFunc type is an adapter to allow the use of ordinary function as ProfileAssignment mutator.

func (ProfileAssignmentFunc) Mutate

Mutate calls f(ctx, m).

type RankOverrideFunc

type RankOverrideFunc func(context.Context, *ent.RankOverrideMutation) (ent.Value, error)

The RankOverrideFunc type is an adapter to allow the use of ordinary function as RankOverride mutator.

func (RankOverrideFunc) Mutate

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

Mutate calls f(ctx, m).

type ReleaseFunc

type ReleaseFunc func(context.Context, *ent.ReleaseMutation) (ent.Value, error)

The ReleaseFunc type is an adapter to allow the use of ordinary function as Release mutator.

func (ReleaseFunc) Mutate

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

Mutate calls f(ctx, m).

type ReportDatasetFunc

type ReportDatasetFunc func(context.Context, *ent.ReportDatasetMutation) (ent.Value, error)

The ReportDatasetFunc type is an adapter to allow the use of ordinary function as ReportDataset mutator.

func (ReportDatasetFunc) Mutate

Mutate calls f(ctx, m).

type SyncMetaFunc

type SyncMetaFunc func(context.Context, *ent.SyncMetaMutation) (ent.Value, error)

The SyncMetaFunc type is an adapter to allow the use of ordinary function as SyncMeta mutator.

func (SyncMetaFunc) Mutate

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