hook

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 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 ActivityEventFunc

type ActivityEventFunc func(context.Context, *ent.ActivityEventMutation) (ent.Value, error)

The ActivityEventFunc type is an adapter to allow the use of ordinary function as ActivityEvent mutator.

func (ActivityEventFunc) Mutate

Mutate calls f(ctx, m).

type AgentFunc

type AgentFunc func(context.Context, *ent.AgentMutation) (ent.Value, error)

The AgentFunc type is an adapter to allow the use of ordinary function as Agent mutator.

func (AgentFunc) Mutate

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

Mutate calls f(ctx, m).

type AgentProviderFunc

type AgentProviderFunc func(context.Context, *ent.AgentProviderMutation) (ent.Value, error)

The AgentProviderFunc type is an adapter to allow the use of ordinary function as AgentProvider mutator.

func (AgentProviderFunc) Mutate

Mutate calls f(ctx, m).

type AgentRunFunc

type AgentRunFunc func(context.Context, *ent.AgentRunMutation) (ent.Value, error)

The AgentRunFunc type is an adapter to allow the use of ordinary function as AgentRun mutator.

func (AgentRunFunc) Mutate

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

Mutate calls f(ctx, m).

type AgentStepEventFunc

type AgentStepEventFunc func(context.Context, *ent.AgentStepEventMutation) (ent.Value, error)

The AgentStepEventFunc type is an adapter to allow the use of ordinary function as AgentStepEvent mutator.

func (AgentStepEventFunc) Mutate

Mutate calls f(ctx, m).

type AgentTokenFunc

type AgentTokenFunc func(context.Context, *ent.AgentTokenMutation) (ent.Value, error)

The AgentTokenFunc type is an adapter to allow the use of ordinary function as AgentToken mutator.

func (AgentTokenFunc) Mutate

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

Mutate calls f(ctx, m).

type AgentTraceEventFunc

type AgentTraceEventFunc func(context.Context, *ent.AgentTraceEventMutation) (ent.Value, error)

The AgentTraceEventFunc type is an adapter to allow the use of ordinary function as AgentTraceEvent mutator.

func (AgentTraceEventFunc) Mutate

Mutate calls f(ctx, m).

type ApprovalPolicyRuleFunc

type ApprovalPolicyRuleFunc func(context.Context, *ent.ApprovalPolicyRuleMutation) (ent.Value, error)

The ApprovalPolicyRuleFunc type is an adapter to allow the use of ordinary function as ApprovalPolicyRule mutator.

func (ApprovalPolicyRuleFunc) Mutate

Mutate calls f(ctx, m).

type BrowserSessionFunc

type BrowserSessionFunc func(context.Context, *ent.BrowserSessionMutation) (ent.Value, error)

The BrowserSessionFunc type is an adapter to allow the use of ordinary function as BrowserSession mutator.

func (BrowserSessionFunc) 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 ChatConversationFunc

type ChatConversationFunc func(context.Context, *ent.ChatConversationMutation) (ent.Value, error)

The ChatConversationFunc type is an adapter to allow the use of ordinary function as ChatConversation mutator.

func (ChatConversationFunc) Mutate

Mutate calls f(ctx, m).

type ChatEntryFunc

type ChatEntryFunc func(context.Context, *ent.ChatEntryMutation) (ent.Value, error)

The ChatEntryFunc type is an adapter to allow the use of ordinary function as ChatEntry mutator.

func (ChatEntryFunc) Mutate

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

Mutate calls f(ctx, m).

type ChatPendingInterruptFunc

type ChatPendingInterruptFunc func(context.Context, *ent.ChatPendingInterruptMutation) (ent.Value, error)

The ChatPendingInterruptFunc type is an adapter to allow the use of ordinary function as ChatPendingInterrupt mutator.

func (ChatPendingInterruptFunc) Mutate

Mutate calls f(ctx, m).

type ChatTurnFunc

type ChatTurnFunc func(context.Context, *ent.ChatTurnMutation) (ent.Value, error)

The ChatTurnFunc type is an adapter to allow the use of ordinary function as ChatTurn mutator.

func (ChatTurnFunc) Mutate

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

type MachineChannelTokenFunc func(context.Context, *ent.MachineChannelTokenMutation) (ent.Value, error)

The MachineChannelTokenFunc type is an adapter to allow the use of ordinary function as MachineChannelToken mutator.

func (MachineChannelTokenFunc) Mutate

Mutate calls f(ctx, m).

type MachineFunc

type MachineFunc func(context.Context, *ent.MachineMutation) (ent.Value, error)

The MachineFunc type is an adapter to allow the use of ordinary function as Machine mutator.

func (MachineFunc) Mutate

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

Mutate calls f(ctx, m).

type NotificationChannelFunc

type NotificationChannelFunc func(context.Context, *ent.NotificationChannelMutation) (ent.Value, error)

The NotificationChannelFunc type is an adapter to allow the use of ordinary function as NotificationChannel mutator.

func (NotificationChannelFunc) Mutate

Mutate calls f(ctx, m).

type NotificationRuleFunc

type NotificationRuleFunc func(context.Context, *ent.NotificationRuleMutation) (ent.Value, error)

The NotificationRuleFunc type is an adapter to allow the use of ordinary function as NotificationRule mutator.

func (NotificationRuleFunc) Mutate

Mutate calls f(ctx, m).

type OrganizationDailyTokenUsageFunc

type OrganizationDailyTokenUsageFunc func(context.Context, *ent.OrganizationDailyTokenUsageMutation) (ent.Value, error)

The OrganizationDailyTokenUsageFunc type is an adapter to allow the use of ordinary function as OrganizationDailyTokenUsage mutator.

func (OrganizationDailyTokenUsageFunc) Mutate

Mutate calls f(ctx, m).

type OrganizationFunc

type OrganizationFunc func(context.Context, *ent.OrganizationMutation) (ent.Value, error)

The OrganizationFunc type is an adapter to allow the use of ordinary function as Organization mutator.

func (OrganizationFunc) Mutate

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

Mutate calls f(ctx, m).

type ProjectConversationPrincipalFunc

type ProjectConversationPrincipalFunc func(context.Context, *ent.ProjectConversationPrincipalMutation) (ent.Value, error)

The ProjectConversationPrincipalFunc type is an adapter to allow the use of ordinary function as ProjectConversationPrincipal mutator.

func (ProjectConversationPrincipalFunc) Mutate

Mutate calls f(ctx, m).

type ProjectConversationRunFunc

type ProjectConversationRunFunc func(context.Context, *ent.ProjectConversationRunMutation) (ent.Value, error)

The ProjectConversationRunFunc type is an adapter to allow the use of ordinary function as ProjectConversationRun mutator.

func (ProjectConversationRunFunc) Mutate

Mutate calls f(ctx, m).

type ProjectConversationStepEventFunc

type ProjectConversationStepEventFunc func(context.Context, *ent.ProjectConversationStepEventMutation) (ent.Value, error)

The ProjectConversationStepEventFunc type is an adapter to allow the use of ordinary function as ProjectConversationStepEvent mutator.

func (ProjectConversationStepEventFunc) Mutate

Mutate calls f(ctx, m).

type ProjectConversationTraceEventFunc

type ProjectConversationTraceEventFunc func(context.Context, *ent.ProjectConversationTraceEventMutation) (ent.Value, error)

The ProjectConversationTraceEventFunc type is an adapter to allow the use of ordinary function as ProjectConversationTraceEvent mutator.

func (ProjectConversationTraceEventFunc) Mutate

Mutate calls f(ctx, m).

type ProjectFunc

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

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

Mutate calls f(ctx, m).

type ProjectRepoFunc

type ProjectRepoFunc func(context.Context, *ent.ProjectRepoMutation) (ent.Value, error)

The ProjectRepoFunc type is an adapter to allow the use of ordinary function as ProjectRepo mutator.

func (ProjectRepoFunc) Mutate

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

Mutate calls f(ctx, m).

type ProjectUpdateCommentFunc

type ProjectUpdateCommentFunc func(context.Context, *ent.ProjectUpdateCommentMutation) (ent.Value, error)

The ProjectUpdateCommentFunc type is an adapter to allow the use of ordinary function as ProjectUpdateComment mutator.

func (ProjectUpdateCommentFunc) Mutate

Mutate calls f(ctx, m).

type ProjectUpdateCommentRevisionFunc

type ProjectUpdateCommentRevisionFunc func(context.Context, *ent.ProjectUpdateCommentRevisionMutation) (ent.Value, error)

The ProjectUpdateCommentRevisionFunc type is an adapter to allow the use of ordinary function as ProjectUpdateCommentRevision mutator.

func (ProjectUpdateCommentRevisionFunc) Mutate

Mutate calls f(ctx, m).

type ProjectUpdateThreadFunc

type ProjectUpdateThreadFunc func(context.Context, *ent.ProjectUpdateThreadMutation) (ent.Value, error)

The ProjectUpdateThreadFunc type is an adapter to allow the use of ordinary function as ProjectUpdateThread mutator.

func (ProjectUpdateThreadFunc) Mutate

Mutate calls f(ctx, m).

type ProjectUpdateThreadRevisionFunc

type ProjectUpdateThreadRevisionFunc func(context.Context, *ent.ProjectUpdateThreadRevisionMutation) (ent.Value, error)

The ProjectUpdateThreadRevisionFunc type is an adapter to allow the use of ordinary function as ProjectUpdateThreadRevision mutator.

func (ProjectUpdateThreadRevisionFunc) Mutate

Mutate calls f(ctx, m).

type RoleBindingFunc

type RoleBindingFunc func(context.Context, *ent.RoleBindingMutation) (ent.Value, error)

The RoleBindingFunc type is an adapter to allow the use of ordinary function as RoleBinding mutator.

func (RoleBindingFunc) Mutate

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

Mutate calls f(ctx, m).

type ScheduledJobFunc

type ScheduledJobFunc func(context.Context, *ent.ScheduledJobMutation) (ent.Value, error)

The ScheduledJobFunc type is an adapter to allow the use of ordinary function as ScheduledJob mutator.

func (ScheduledJobFunc) Mutate

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

Mutate calls f(ctx, m).

type SkillBlobFunc

type SkillBlobFunc func(context.Context, *ent.SkillBlobMutation) (ent.Value, error)

The SkillBlobFunc type is an adapter to allow the use of ordinary function as SkillBlob mutator.

func (SkillBlobFunc) Mutate

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

Mutate calls f(ctx, m).

type SkillFunc

type SkillFunc func(context.Context, *ent.SkillMutation) (ent.Value, error)

The SkillFunc type is an adapter to allow the use of ordinary function as Skill mutator.

func (SkillFunc) Mutate

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

Mutate calls f(ctx, m).

type SkillVersionFileFunc

type SkillVersionFileFunc func(context.Context, *ent.SkillVersionFileMutation) (ent.Value, error)

The SkillVersionFileFunc type is an adapter to allow the use of ordinary function as SkillVersionFile mutator.

func (SkillVersionFileFunc) Mutate

Mutate calls f(ctx, m).

type SkillVersionFunc

type SkillVersionFunc func(context.Context, *ent.SkillVersionMutation) (ent.Value, error)

The SkillVersionFunc type is an adapter to allow the use of ordinary function as SkillVersion mutator.

func (SkillVersionFunc) Mutate

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

Mutate calls f(ctx, m).

type TicketCommentFunc

type TicketCommentFunc func(context.Context, *ent.TicketCommentMutation) (ent.Value, error)

The TicketCommentFunc type is an adapter to allow the use of ordinary function as TicketComment mutator.

func (TicketCommentFunc) Mutate

Mutate calls f(ctx, m).

type TicketCommentRevisionFunc

type TicketCommentRevisionFunc func(context.Context, *ent.TicketCommentRevisionMutation) (ent.Value, error)

The TicketCommentRevisionFunc type is an adapter to allow the use of ordinary function as TicketCommentRevision mutator.

func (TicketCommentRevisionFunc) Mutate

Mutate calls f(ctx, m).

type TicketDependencyFunc

type TicketDependencyFunc func(context.Context, *ent.TicketDependencyMutation) (ent.Value, error)

The TicketDependencyFunc type is an adapter to allow the use of ordinary function as TicketDependency mutator.

func (TicketDependencyFunc) Mutate

Mutate calls f(ctx, m).

type TicketExternalLinkFunc

type TicketExternalLinkFunc func(context.Context, *ent.TicketExternalLinkMutation) (ent.Value, error)

The TicketExternalLinkFunc type is an adapter to allow the use of ordinary function as TicketExternalLink mutator.

func (TicketExternalLinkFunc) Mutate

Mutate calls f(ctx, m).

type TicketFunc

type TicketFunc func(context.Context, *ent.TicketMutation) (ent.Value, error)

The TicketFunc type is an adapter to allow the use of ordinary function as Ticket mutator.

func (TicketFunc) Mutate

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

Mutate calls f(ctx, m).

type TicketRepoScopeFunc

type TicketRepoScopeFunc func(context.Context, *ent.TicketRepoScopeMutation) (ent.Value, error)

The TicketRepoScopeFunc type is an adapter to allow the use of ordinary function as TicketRepoScope mutator.

func (TicketRepoScopeFunc) Mutate

Mutate calls f(ctx, m).

type TicketRepoWorkspaceFunc

type TicketRepoWorkspaceFunc func(context.Context, *ent.TicketRepoWorkspaceMutation) (ent.Value, error)

The TicketRepoWorkspaceFunc type is an adapter to allow the use of ordinary function as TicketRepoWorkspace mutator.

func (TicketRepoWorkspaceFunc) Mutate

Mutate calls f(ctx, m).

type TicketStatusFunc

type TicketStatusFunc func(context.Context, *ent.TicketStatusMutation) (ent.Value, error)

The TicketStatusFunc type is an adapter to allow the use of ordinary function as TicketStatus mutator.

func (TicketStatusFunc) Mutate

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

type UserGroupMembershipFunc func(context.Context, *ent.UserGroupMembershipMutation) (ent.Value, error)

The UserGroupMembershipFunc type is an adapter to allow the use of ordinary function as UserGroupMembership mutator.

func (UserGroupMembershipFunc) Mutate

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 WorkflowFunc

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

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

Mutate calls f(ctx, m).

type WorkflowSkillBindingFunc

type WorkflowSkillBindingFunc func(context.Context, *ent.WorkflowSkillBindingMutation) (ent.Value, error)

The WorkflowSkillBindingFunc type is an adapter to allow the use of ordinary function as WorkflowSkillBinding mutator.

func (WorkflowSkillBindingFunc) Mutate

Mutate calls f(ctx, m).

type WorkflowVersionFunc

type WorkflowVersionFunc func(context.Context, *ent.WorkflowVersionMutation) (ent.Value, error)

The WorkflowVersionFunc type is an adapter to allow the use of ordinary function as WorkflowVersion mutator.

func (WorkflowVersionFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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