Help us shape the future of Go! Take the 2026 Go Developer Survey

hook

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 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 ApiTokenFunc

type ApiTokenFunc func(context.Context, *ent.ApiTokenMutation) (ent.Value, error)

The ApiTokenFunc type is an adapter to allow the use of ordinary function as ApiToken mutator.

func (ApiTokenFunc) Mutate

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

Mutate calls f(ctx, m).

type AuditEntryFunc

type AuditEntryFunc func(context.Context, *ent.AuditEntryMutation) (ent.Value, error)

The AuditEntryFunc type is an adapter to allow the use of ordinary function as AuditEntry mutator.

func (AuditEntryFunc) Mutate

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

Mutate calls f(ctx, m).

type AuthAttemptFunc

type AuthAttemptFunc func(context.Context, *ent.AuthAttemptMutation) (ent.Value, error)

The AuthAttemptFunc type is an adapter to allow the use of ordinary function as AuthAttempt mutator.

func (AuthAttemptFunc) Mutate

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

Mutate calls f(ctx, m).

type AutomationFunc

type AutomationFunc func(context.Context, *ent.AutomationMutation) (ent.Value, error)

The AutomationFunc type is an adapter to allow the use of ordinary function as Automation mutator.

func (AutomationFunc) Mutate

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

Mutate calls f(ctx, m).

type AutomationRunFunc

type AutomationRunFunc func(context.Context, *ent.AutomationRunMutation) (ent.Value, error)

The AutomationRunFunc type is an adapter to allow the use of ordinary function as AutomationRun mutator.

func (AutomationRunFunc) Mutate

Mutate calls f(ctx, m).

type AutomationVersionFunc

type AutomationVersionFunc func(context.Context, *ent.AutomationVersionMutation) (ent.Value, error)

The AutomationVersionFunc type is an adapter to allow the use of ordinary function as AutomationVersion mutator.

func (AutomationVersionFunc) Mutate

Mutate calls f(ctx, m).

type BrandKitFunc

type BrandKitFunc func(context.Context, *ent.BrandKitMutation) (ent.Value, error)

The BrandKitFunc type is an adapter to allow the use of ordinary function as BrandKit mutator.

func (BrandKitFunc) Mutate

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

Mutate calls f(ctx, m).

type BroadcastFunc

type BroadcastFunc func(context.Context, *ent.BroadcastMutation) (ent.Value, error)

The BroadcastFunc type is an adapter to allow the use of ordinary function as Broadcast mutator.

func (BroadcastFunc) Mutate

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

Mutate calls f(ctx, m).

type BroadcastRecipientFunc

type BroadcastRecipientFunc func(context.Context, *ent.BroadcastRecipientMutation) (ent.Value, error)

The BroadcastRecipientFunc type is an adapter to allow the use of ordinary function as BroadcastRecipient mutator.

func (BroadcastRecipientFunc) 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 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 ConfirmationFunc

type ConfirmationFunc func(context.Context, *ent.ConfirmationMutation) (ent.Value, error)

The ConfirmationFunc type is an adapter to allow the use of ordinary function as Confirmation mutator.

func (ConfirmationFunc) Mutate

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

Mutate calls f(ctx, m).

type ContactFunc

type ContactFunc func(context.Context, *ent.ContactMutation) (ent.Value, error)

The ContactFunc type is an adapter to allow the use of ordinary function as Contact mutator.

func (ContactFunc) Mutate

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

Mutate calls f(ctx, m).

type ContactTagFunc

type ContactTagFunc func(context.Context, *ent.ContactTagMutation) (ent.Value, error)

The ContactTagFunc type is an adapter to allow the use of ordinary function as ContactTag mutator.

func (ContactTagFunc) Mutate

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

Mutate calls f(ctx, m).

type CustomFieldFunc

type CustomFieldFunc func(context.Context, *ent.CustomFieldMutation) (ent.Value, error)

The CustomFieldFunc type is an adapter to allow the use of ordinary function as CustomField mutator.

func (CustomFieldFunc) Mutate

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

Mutate calls f(ctx, m).

type EmailTemplateFunc

type EmailTemplateFunc func(context.Context, *ent.EmailTemplateMutation) (ent.Value, error)

The EmailTemplateFunc type is an adapter to allow the use of ordinary function as EmailTemplate mutator.

func (EmailTemplateFunc) Mutate

Mutate calls f(ctx, m).

type ErasureFunc

type ErasureFunc func(context.Context, *ent.ErasureMutation) (ent.Value, error)

The ErasureFunc type is an adapter to allow the use of ordinary function as Erasure mutator.

func (ErasureFunc) Mutate

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

Mutate calls f(ctx, m).

type EventFunc

type EventFunc func(context.Context, *ent.EventMutation) (ent.Value, error)

The EventFunc type is an adapter to allow the use of ordinary function as Event mutator.

func (EventFunc) Mutate

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

Mutate calls f(ctx, m).

type HoldFunc

type HoldFunc func(context.Context, *ent.HoldMutation) (ent.Value, error)

The HoldFunc type is an adapter to allow the use of ordinary function as Hold mutator.

func (HoldFunc) Mutate

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

Mutate calls f(ctx, m).

type InstanceStateFunc

type InstanceStateFunc func(context.Context, *ent.InstanceStateMutation) (ent.Value, error)

The InstanceStateFunc type is an adapter to allow the use of ordinary function as InstanceState mutator.

func (InstanceStateFunc) Mutate

Mutate calls f(ctx, m).

type IntegrationFunc

type IntegrationFunc func(context.Context, *ent.IntegrationMutation) (ent.Value, error)

The IntegrationFunc type is an adapter to allow the use of ordinary function as Integration mutator.

func (IntegrationFunc) Mutate

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

Mutate calls f(ctx, m).

type InvitationFunc

type InvitationFunc func(context.Context, *ent.InvitationMutation) (ent.Value, error)

The InvitationFunc type is an adapter to allow the use of ordinary function as Invitation mutator.

func (InvitationFunc) Mutate

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

Mutate calls f(ctx, m).

type JoinDomainFunc

type JoinDomainFunc func(context.Context, *ent.JoinDomainMutation) (ent.Value, error)

The JoinDomainFunc type is an adapter to allow the use of ordinary function as JoinDomain mutator.

func (JoinDomainFunc) Mutate

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

Mutate calls f(ctx, m).

type MembershipFunc

type MembershipFunc func(context.Context, *ent.MembershipMutation) (ent.Value, error)

The MembershipFunc type is an adapter to allow the use of ordinary function as Membership mutator.

func (MembershipFunc) Mutate

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

Mutate calls f(ctx, m).

type OAuthClientFunc

type OAuthClientFunc func(context.Context, *ent.OAuthClientMutation) (ent.Value, error)

The OAuthClientFunc type is an adapter to allow the use of ordinary function as OAuthClient mutator.

func (OAuthClientFunc) Mutate

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

Mutate calls f(ctx, m).

type OAuthCodeFunc

type OAuthCodeFunc func(context.Context, *ent.OAuthCodeMutation) (ent.Value, error)

The OAuthCodeFunc type is an adapter to allow the use of ordinary function as OAuthCode mutator.

func (OAuthCodeFunc) Mutate

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

Mutate calls f(ctx, m).

type OAuthRefreshTokenFunc

type OAuthRefreshTokenFunc func(context.Context, *ent.OAuthRefreshTokenMutation) (ent.Value, error)

The OAuthRefreshTokenFunc type is an adapter to allow the use of ordinary function as OAuthRefreshToken mutator.

func (OAuthRefreshTokenFunc) Mutate

Mutate calls f(ctx, m).

type OutboundMessageFunc

type OutboundMessageFunc func(context.Context, *ent.OutboundMessageMutation) (ent.Value, error)

The OutboundMessageFunc type is an adapter to allow the use of ordinary function as OutboundMessage mutator.

func (OutboundMessageFunc) Mutate

Mutate calls f(ctx, m).

type OutboxMessageFunc

type OutboxMessageFunc func(context.Context, *ent.OutboxMessageMutation) (ent.Value, error)

The OutboxMessageFunc type is an adapter to allow the use of ordinary function as OutboxMessage mutator.

func (OutboxMessageFunc) Mutate

Mutate calls f(ctx, m).

type OutboxOffsetFunc

type OutboxOffsetFunc func(context.Context, *ent.OutboxOffsetMutation) (ent.Value, error)

The OutboxOffsetFunc type is an adapter to allow the use of ordinary function as OutboxOffset mutator.

func (OutboxOffsetFunc) Mutate

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

Mutate calls f(ctx, m).

type PasskeyChallengeFunc

type PasskeyChallengeFunc func(context.Context, *ent.PasskeyChallengeMutation) (ent.Value, error)

The PasskeyChallengeFunc type is an adapter to allow the use of ordinary function as PasskeyChallenge mutator.

func (PasskeyChallengeFunc) Mutate

Mutate calls f(ctx, m).

type PasskeyFunc

type PasskeyFunc func(context.Context, *ent.PasskeyMutation) (ent.Value, error)

The PasskeyFunc type is an adapter to allow the use of ordinary function as Passkey mutator.

func (PasskeyFunc) Mutate

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

Mutate calls f(ctx, m).

type RecoveryCodeFunc

type RecoveryCodeFunc func(context.Context, *ent.RecoveryCodeMutation) (ent.Value, error)

The RecoveryCodeFunc type is an adapter to allow the use of ordinary function as RecoveryCode mutator.

func (RecoveryCodeFunc) Mutate

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

Mutate calls f(ctx, m).

type RiverJobFunc

type RiverJobFunc func(context.Context, *ent.RiverJobMutation) (ent.Value, error)

The RiverJobFunc type is an adapter to allow the use of ordinary function as RiverJob mutator.

func (RiverJobFunc) Mutate

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

Mutate calls f(ctx, m).

type SchemaStateFunc

type SchemaStateFunc func(context.Context, *ent.SchemaStateMutation) (ent.Value, error)

The SchemaStateFunc type is an adapter to allow the use of ordinary function as SchemaState mutator.

func (SchemaStateFunc) Mutate

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

Mutate calls f(ctx, m).

type SegmentFunc

type SegmentFunc func(context.Context, *ent.SegmentMutation) (ent.Value, error)

The SegmentFunc type is an adapter to allow the use of ordinary function as Segment mutator.

func (SegmentFunc) Mutate

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

Mutate calls f(ctx, m).

type SendLimiterFunc

type SendLimiterFunc func(context.Context, *ent.SendLimiterMutation) (ent.Value, error)

The SendLimiterFunc type is an adapter to allow the use of ordinary function as SendLimiter mutator.

func (SendLimiterFunc) Mutate

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

Mutate calls f(ctx, m).

type SendingDomainFunc

type SendingDomainFunc func(context.Context, *ent.SendingDomainMutation) (ent.Value, error)

The SendingDomainFunc type is an adapter to allow the use of ordinary function as SendingDomain mutator.

func (SendingDomainFunc) Mutate

Mutate calls f(ctx, m).

type ServiceCredentialFunc

type ServiceCredentialFunc func(context.Context, *ent.ServiceCredentialMutation) (ent.Value, error)

The ServiceCredentialFunc type is an adapter to allow the use of ordinary function as ServiceCredential mutator.

func (ServiceCredentialFunc) Mutate

Mutate calls f(ctx, m).

type StaffMemberFunc

type StaffMemberFunc func(context.Context, *ent.StaffMemberMutation) (ent.Value, error)

The StaffMemberFunc type is an adapter to allow the use of ordinary function as StaffMember mutator.

func (StaffMemberFunc) Mutate

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

Mutate calls f(ctx, m).

type SuppressionFunc

type SuppressionFunc func(context.Context, *ent.SuppressionMutation) (ent.Value, error)

The SuppressionFunc type is an adapter to allow the use of ordinary function as Suppression mutator.

func (SuppressionFunc) Mutate

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

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 TrackingHostChangeFunc

type TrackingHostChangeFunc func(context.Context, *ent.TrackingHostChangeMutation) (ent.Value, error)

The TrackingHostChangeFunc type is an adapter to allow the use of ordinary function as TrackingHostChange mutator.

func (TrackingHostChangeFunc) Mutate

Mutate calls f(ctx, m).

type UnsubscribeFunc

type UnsubscribeFunc func(context.Context, *ent.UnsubscribeMutation) (ent.Value, error)

The UnsubscribeFunc type is an adapter to allow the use of ordinary function as Unsubscribe mutator.

func (UnsubscribeFunc) Mutate

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

Mutate calls f(ctx, m).

type UsageFunc

type UsageFunc func(context.Context, *ent.UsageMutation) (ent.Value, error)

The UsageFunc type is an adapter to allow the use of ordinary function as Usage mutator.

func (UsageFunc) Mutate

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

Mutate calls f(ctx, m).

type UserFunc

type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)

The UserFunc type is an adapter to allow the use of ordinary function as User mutator.

func (UserFunc) Mutate

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

Mutate calls f(ctx, m).

type UserIdentityFunc

type UserIdentityFunc func(context.Context, *ent.UserIdentityMutation) (ent.Value, error)

The UserIdentityFunc type is an adapter to allow the use of ordinary function as UserIdentity mutator.

func (UserIdentityFunc) Mutate

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

Mutate calls f(ctx, m).

type VisitorFunc

type VisitorFunc func(context.Context, *ent.VisitorMutation) (ent.Value, error)

The VisitorFunc type is an adapter to allow the use of ordinary function as Visitor mutator.

func (VisitorFunc) Mutate

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

Mutate calls f(ctx, m).

type WebhookEndpointFunc

type WebhookEndpointFunc func(context.Context, *ent.WebhookEndpointMutation) (ent.Value, error)

The WebhookEndpointFunc type is an adapter to allow the use of ordinary function as WebhookEndpoint mutator.

func (WebhookEndpointFunc) Mutate

Mutate calls f(ctx, m).

type WorkspaceFunc

type WorkspaceFunc func(context.Context, *ent.WorkspaceMutation) (ent.Value, error)

The WorkspaceFunc type is an adapter to allow the use of ordinary function as Workspace mutator.

func (WorkspaceFunc) Mutate

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