hook

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 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 ActionLogFunc added in v0.7.0

type ActionLogFunc func(context.Context, *ent.ActionLogMutation) (ent.Value, error)

The ActionLogFunc type is an adapter to allow the use of ordinary function as ActionLog mutator.

func (ActionLogFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type AgentMemoryFunc added in v0.7.0

type AgentMemoryFunc func(context.Context, *ent.AgentMemoryMutation) (ent.Value, error)

The AgentMemoryFunc type is an adapter to allow the use of ordinary function as AgentMemory mutator.

func (AgentMemoryFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type AuditLogFunc

type AuditLogFunc func(context.Context, *ent.AuditLogMutation) (ent.Value, error)

The AuditLogFunc type is an adapter to allow the use of ordinary function as AuditLog mutator.

func (AuditLogFunc) Mutate

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

type ConfigProfileFunc func(context.Context, *ent.ConfigProfileMutation) (ent.Value, error)

The ConfigProfileFunc type is an adapter to allow the use of ordinary function as ConfigProfile mutator.

func (ConfigProfileFunc) Mutate

Mutate calls f(ctx, m).

type CronJobFunc

type CronJobFunc func(context.Context, *ent.CronJobMutation) (ent.Value, error)

The CronJobFunc type is an adapter to allow the use of ordinary function as CronJob mutator.

func (CronJobFunc) Mutate

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

Mutate calls f(ctx, m).

type CronJobHistoryFunc

type CronJobHistoryFunc func(context.Context, *ent.CronJobHistoryMutation) (ent.Value, error)

The CronJobHistoryFunc type is an adapter to allow the use of ordinary function as CronJobHistory mutator.

func (CronJobHistoryFunc) Mutate

Mutate calls f(ctx, m).

type EntityAliasFunc added in v0.7.0

type EntityAliasFunc func(context.Context, *ent.EntityAliasMutation) (ent.Value, error)

The EntityAliasFunc type is an adapter to allow the use of ordinary function as EntityAlias mutator.

func (EntityAliasFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type EntityPropertyFunc added in v0.7.0

type EntityPropertyFunc func(context.Context, *ent.EntityPropertyMutation) (ent.Value, error)

The EntityPropertyFunc type is an adapter to allow the use of ordinary function as EntityProperty mutator.

func (EntityPropertyFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type EscrowDealFunc added in v0.5.0

type EscrowDealFunc func(context.Context, *ent.EscrowDealMutation) (ent.Value, error)

The EscrowDealFunc type is an adapter to allow the use of ordinary function as EscrowDeal mutator.

func (EscrowDealFunc) Mutate added in v0.5.0

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

Mutate calls f(ctx, m).

type ExternalRefFunc

type ExternalRefFunc func(context.Context, *ent.ExternalRefMutation) (ent.Value, error)

The ExternalRefFunc type is an adapter to allow the use of ordinary function as ExternalRef mutator.

func (ExternalRefFunc) Mutate

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

Mutate calls f(ctx, m).

type InquiryFunc

type InquiryFunc func(context.Context, *ent.InquiryMutation) (ent.Value, error)

The InquiryFunc type is an adapter to allow the use of ordinary function as Inquiry mutator.

func (InquiryFunc) Mutate

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

Mutate calls f(ctx, m).

type KeyFunc

type KeyFunc func(context.Context, *ent.KeyMutation) (ent.Value, error)

The KeyFunc type is an adapter to allow the use of ordinary function as Key mutator.

func (KeyFunc) Mutate

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

Mutate calls f(ctx, m).

type KnowledgeFunc

type KnowledgeFunc func(context.Context, *ent.KnowledgeMutation) (ent.Value, error)

The KnowledgeFunc type is an adapter to allow the use of ordinary function as Knowledge mutator.

func (KnowledgeFunc) Mutate

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

Mutate calls f(ctx, m).

type LearningFunc

type LearningFunc func(context.Context, *ent.LearningMutation) (ent.Value, error)

The LearningFunc type is an adapter to allow the use of ordinary function as Learning mutator.

func (LearningFunc) Mutate

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

Mutate calls f(ctx, m).

type MessageFunc

type MessageFunc func(context.Context, *ent.MessageMutation) (ent.Value, error)

The MessageFunc type is an adapter to allow the use of ordinary function as Message mutator.

func (MessageFunc) Mutate

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

Mutate calls f(ctx, m).

type ObservationFunc

type ObservationFunc func(context.Context, *ent.ObservationMutation) (ent.Value, error)

The ObservationFunc type is an adapter to allow the use of ordinary function as Observation mutator.

func (ObservationFunc) Mutate

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

Mutate calls f(ctx, m).

type OntologyConflictFunc added in v0.7.0

type OntologyConflictFunc func(context.Context, *ent.OntologyConflictMutation) (ent.Value, error)

The OntologyConflictFunc type is an adapter to allow the use of ordinary function as OntologyConflict mutator.

func (OntologyConflictFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type OntologyPredicateFunc added in v0.7.0

type OntologyPredicateFunc func(context.Context, *ent.OntologyPredicateMutation) (ent.Value, error)

The OntologyPredicateFunc type is an adapter to allow the use of ordinary function as OntologyPredicate mutator.

func (OntologyPredicateFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type OntologyTypeFunc added in v0.7.0

type OntologyTypeFunc func(context.Context, *ent.OntologyTypeMutation) (ent.Value, error)

The OntologyTypeFunc type is an adapter to allow the use of ordinary function as OntologyType mutator.

func (OntologyTypeFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type PaymentTxFunc

type PaymentTxFunc func(context.Context, *ent.PaymentTxMutation) (ent.Value, error)

The PaymentTxFunc type is an adapter to allow the use of ordinary function as PaymentTx mutator.

func (PaymentTxFunc) Mutate

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

Mutate calls f(ctx, m).

type PeerReputationFunc

type PeerReputationFunc func(context.Context, *ent.PeerReputationMutation) (ent.Value, error)

The PeerReputationFunc type is an adapter to allow the use of ordinary function as PeerReputation mutator.

func (PeerReputationFunc) Mutate

Mutate calls f(ctx, m).

type ProvenanceAttributionFunc added in v0.7.0

type ProvenanceAttributionFunc func(context.Context, *ent.ProvenanceAttributionMutation) (ent.Value, error)

The ProvenanceAttributionFunc type is an adapter to allow the use of ordinary function as ProvenanceAttribution mutator.

func (ProvenanceAttributionFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type ProvenanceCheckpointFunc added in v0.7.0

type ProvenanceCheckpointFunc func(context.Context, *ent.ProvenanceCheckpointMutation) (ent.Value, error)

The ProvenanceCheckpointFunc type is an adapter to allow the use of ordinary function as ProvenanceCheckpoint mutator.

func (ProvenanceCheckpointFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type ReflectionFunc

type ReflectionFunc func(context.Context, *ent.ReflectionMutation) (ent.Value, error)

The ReflectionFunc type is an adapter to allow the use of ordinary function as Reflection mutator.

func (ReflectionFunc) Mutate

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

Mutate calls f(ctx, m).

type RunJournalFunc added in v0.7.0

type RunJournalFunc func(context.Context, *ent.RunJournalMutation) (ent.Value, error)

The RunJournalFunc type is an adapter to allow the use of ordinary function as RunJournal mutator.

func (RunJournalFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type RunSnapshotFunc added in v0.7.0

type RunSnapshotFunc func(context.Context, *ent.RunSnapshotMutation) (ent.Value, error)

The RunSnapshotFunc type is an adapter to allow the use of ordinary function as RunSnapshot mutator.

func (RunSnapshotFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type RunStepFunc added in v0.7.0

type RunStepFunc func(context.Context, *ent.RunStepMutation) (ent.Value, error)

The RunStepFunc type is an adapter to allow the use of ordinary function as RunStep mutator.

func (RunStepFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type SecretFunc

type SecretFunc func(context.Context, *ent.SecretMutation) (ent.Value, error)

The SecretFunc type is an adapter to allow the use of ordinary function as Secret mutator.

func (SecretFunc) Mutate

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

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 SessionProvenanceFunc added in v0.7.0

type SessionProvenanceFunc func(context.Context, *ent.SessionProvenanceMutation) (ent.Value, error)

The SessionProvenanceFunc type is an adapter to allow the use of ordinary function as SessionProvenance mutator.

func (SessionProvenanceFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type TokenUsageFunc added in v0.5.0

type TokenUsageFunc func(context.Context, *ent.TokenUsageMutation) (ent.Value, error)

The TokenUsageFunc type is an adapter to allow the use of ordinary function as TokenUsage mutator.

func (TokenUsageFunc) Mutate added in v0.5.0

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

Mutate calls f(ctx, m).

type TurnTraceEventFunc added in v0.7.0

type TurnTraceEventFunc func(context.Context, *ent.TurnTraceEventMutation) (ent.Value, error)

The TurnTraceEventFunc type is an adapter to allow the use of ordinary function as TurnTraceEvent mutator.

func (TurnTraceEventFunc) Mutate added in v0.7.0

Mutate calls f(ctx, m).

type TurnTraceFunc added in v0.7.0

type TurnTraceFunc func(context.Context, *ent.TurnTraceMutation) (ent.Value, error)

The TurnTraceFunc type is an adapter to allow the use of ordinary function as TurnTrace mutator.

func (TurnTraceFunc) Mutate added in v0.7.0

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

Mutate calls f(ctx, m).

type WorkflowRunFunc

type WorkflowRunFunc func(context.Context, *ent.WorkflowRunMutation) (ent.Value, error)

The WorkflowRunFunc type is an adapter to allow the use of ordinary function as WorkflowRun mutator.

func (WorkflowRunFunc) Mutate

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

Mutate calls f(ctx, m).

type WorkflowStepRunFunc

type WorkflowStepRunFunc func(context.Context, *ent.WorkflowStepRunMutation) (ent.Value, error)

The WorkflowStepRunFunc type is an adapter to allow the use of ordinary function as WorkflowStepRun mutator.

func (WorkflowStepRunFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL