hook

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: Apache-2.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 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 AntivirusFunc

type AntivirusFunc func(context.Context, *ent.AntivirusMutation) (ent.Value, error)

The AntivirusFunc type is an adapter to allow the use of ordinary function as Antivirus mutator.

func (AntivirusFunc) Mutate

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

Mutate calls f(ctx, m).

type AppFunc

type AppFunc func(context.Context, *ent.AppMutation) (ent.Value, error)

The AppFunc type is an adapter to allow the use of ordinary function as App mutator.

func (AppFunc) Mutate

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

Mutate calls f(ctx, m).

type AuthenticationFunc

type AuthenticationFunc func(context.Context, *ent.AuthenticationMutation) (ent.Value, error)

The AuthenticationFunc type is an adapter to allow the use of ordinary function as Authentication mutator.

func (AuthenticationFunc) Mutate

Mutate calls f(ctx, m).

type CertificateFunc

type CertificateFunc func(context.Context, *ent.CertificateMutation) (ent.Value, error)

The CertificateFunc type is an adapter to allow the use of ordinary function as Certificate mutator.

func (CertificateFunc) Mutate

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

type ComputerFunc func(context.Context, *ent.ComputerMutation) (ent.Value, error)

The ComputerFunc type is an adapter to allow the use of ordinary function as Computer mutator.

func (ComputerFunc) Mutate

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

type DeploymentFunc func(context.Context, *ent.DeploymentMutation) (ent.Value, error)

The DeploymentFunc type is an adapter to allow the use of ordinary function as Deployment mutator.

func (DeploymentFunc) Mutate

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

Mutate calls f(ctx, m).

type LogicalDiskFunc

type LogicalDiskFunc func(context.Context, *ent.LogicalDiskMutation) (ent.Value, error)

The LogicalDiskFunc type is an adapter to allow the use of ordinary function as LogicalDisk mutator.

func (LogicalDiskFunc) Mutate

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

Mutate calls f(ctx, m).

type MemorySlotFunc

type MemorySlotFunc func(context.Context, *ent.MemorySlotMutation) (ent.Value, error)

The MemorySlotFunc type is an adapter to allow the use of ordinary function as MemorySlot mutator.

func (MemorySlotFunc) Mutate

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

Mutate calls f(ctx, m).

type MetadataFunc

type MetadataFunc func(context.Context, *ent.MetadataMutation) (ent.Value, error)

The MetadataFunc type is an adapter to allow the use of ordinary function as Metadata mutator.

func (MetadataFunc) Mutate

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

Mutate calls f(ctx, m).

type MonitorFunc

type MonitorFunc func(context.Context, *ent.MonitorMutation) (ent.Value, error)

The MonitorFunc type is an adapter to allow the use of ordinary function as Monitor mutator.

func (MonitorFunc) Mutate

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

Mutate calls f(ctx, m).

type NetworkAdapterFunc

type NetworkAdapterFunc func(context.Context, *ent.NetworkAdapterMutation) (ent.Value, error)

The NetworkAdapterFunc type is an adapter to allow the use of ordinary function as NetworkAdapter mutator.

func (NetworkAdapterFunc) Mutate

Mutate calls f(ctx, m).

type OperatingSystemFunc

type OperatingSystemFunc func(context.Context, *ent.OperatingSystemMutation) (ent.Value, error)

The OperatingSystemFunc type is an adapter to allow the use of ordinary function as OperatingSystem mutator.

func (OperatingSystemFunc) Mutate

Mutate calls f(ctx, m).

type OrgMetadataFunc

type OrgMetadataFunc func(context.Context, *ent.OrgMetadataMutation) (ent.Value, error)

The OrgMetadataFunc type is an adapter to allow the use of ordinary function as OrgMetadata mutator.

func (OrgMetadataFunc) Mutate

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

Mutate calls f(ctx, m).

type PhysicalDiskFunc

type PhysicalDiskFunc func(context.Context, *ent.PhysicalDiskMutation) (ent.Value, error)

The PhysicalDiskFunc type is an adapter to allow the use of ordinary function as PhysicalDisk mutator.

func (PhysicalDiskFunc) Mutate

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

Mutate calls f(ctx, m).

type PrinterFunc

type PrinterFunc func(context.Context, *ent.PrinterMutation) (ent.Value, error)

The PrinterFunc type is an adapter to allow the use of ordinary function as Printer mutator.

func (PrinterFunc) Mutate

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

Mutate calls f(ctx, m).

type ProfileFunc

type ProfileFunc func(context.Context, *ent.ProfileMutation) (ent.Value, error)

The ProfileFunc type is an adapter to allow the use of ordinary function as Profile mutator.

func (ProfileFunc) Mutate

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

Mutate calls f(ctx, m).

type ProfileIssueFunc

type ProfileIssueFunc func(context.Context, *ent.ProfileIssueMutation) (ent.Value, error)

The ProfileIssueFunc type is an adapter to allow the use of ordinary function as ProfileIssue mutator.

func (ProfileIssueFunc) Mutate

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

type RevocationFunc func(context.Context, *ent.RevocationMutation) (ent.Value, error)

The RevocationFunc type is an adapter to allow the use of ordinary function as Revocation mutator.

func (RevocationFunc) Mutate

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

Mutate calls f(ctx, m).

type RustdeskFunc

type RustdeskFunc func(context.Context, *ent.RustdeskMutation) (ent.Value, error)

The RustdeskFunc type is an adapter to allow the use of ordinary function as Rustdesk mutator.

func (RustdeskFunc) Mutate

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

Mutate calls f(ctx, m).

type ServerFunc

type ServerFunc func(context.Context, *ent.ServerMutation) (ent.Value, error)

The ServerFunc type is an adapter to allow the use of ordinary function as Server mutator.

func (ServerFunc) Mutate

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

Mutate calls f(ctx, m).

type SessionsFunc

type SessionsFunc func(context.Context, *ent.SessionsMutation) (ent.Value, error)

The SessionsFunc type is an adapter to allow the use of ordinary function as Sessions mutator.

func (SessionsFunc) Mutate

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

Mutate calls f(ctx, m).

type SettingsFunc

type SettingsFunc func(context.Context, *ent.SettingsMutation) (ent.Value, error)

The SettingsFunc type is an adapter to allow the use of ordinary function as Settings mutator.

func (SettingsFunc) Mutate

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

Mutate calls f(ctx, m).

type ShareFunc

type ShareFunc func(context.Context, *ent.ShareMutation) (ent.Value, error)

The ShareFunc type is an adapter to allow the use of ordinary function as Share mutator.

func (ShareFunc) Mutate

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

Mutate calls f(ctx, m).

type SiteFunc

type SiteFunc func(context.Context, *ent.SiteMutation) (ent.Value, error)

The SiteFunc type is an adapter to allow the use of ordinary function as Site mutator.

func (SiteFunc) Mutate

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

Mutate calls f(ctx, m).

type SystemUpdateFunc

type SystemUpdateFunc func(context.Context, *ent.SystemUpdateMutation) (ent.Value, error)

The SystemUpdateFunc type is an adapter to allow the use of ordinary function as SystemUpdate mutator.

func (SystemUpdateFunc) Mutate

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

type TaskFunc func(context.Context, *ent.TaskMutation) (ent.Value, error)

The TaskFunc type is an adapter to allow the use of ordinary function as Task mutator.

func (TaskFunc) Mutate

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

Mutate calls f(ctx, m).

type TenantFunc

type TenantFunc func(context.Context, *ent.TenantMutation) (ent.Value, error)

The TenantFunc type is an adapter to allow the use of ordinary function as Tenant mutator.

func (TenantFunc) Mutate

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

Mutate calls f(ctx, m).

type UpdateFunc

type UpdateFunc func(context.Context, *ent.UpdateMutation) (ent.Value, error)

The UpdateFunc type is an adapter to allow the use of ordinary function as Update mutator.

func (UpdateFunc) Mutate

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

type WingetConfigExclusionFunc func(context.Context, *ent.WingetConfigExclusionMutation) (ent.Value, error)

The WingetConfigExclusionFunc type is an adapter to allow the use of ordinary function as WingetConfigExclusion mutator.

func (WingetConfigExclusionFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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