hook

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 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 APIPermissionFunc

type APIPermissionFunc func(context.Context, *ent.APIPermissionMutation) (ent.Value, error)

The APIPermissionFunc type is an adapter to allow the use of ordinary function as APIPermission mutator.

func (APIPermissionFunc) Mutate

Mutate calls f(ctx, m).

type APIPermissionMapFunc

type APIPermissionMapFunc func(context.Context, *ent.APIPermissionMapMutation) (ent.Value, error)

The APIPermissionMapFunc type is an adapter to allow the use of ordinary function as APIPermissionMap mutator.

func (APIPermissionMapFunc) Mutate

Mutate calls f(ctx, m).

type ApiKeyFunc

type ApiKeyFunc func(context.Context, *ent.ApiKeyMutation) (ent.Value, error)

The ApiKeyFunc type is an adapter to allow the use of ordinary function as ApiKey mutator.

func (ApiKeyFunc) Mutate

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

type DictionaryDetailFunc func(context.Context, *ent.DictionaryDetailMutation) (ent.Value, error)

The DictionaryDetailFunc type is an adapter to allow the use of ordinary function as DictionaryDetail mutator.

func (DictionaryDetailFunc) Mutate

Mutate calls f(ctx, m).

type DictionaryFunc

type DictionaryFunc func(context.Context, *ent.DictionaryMutation) (ent.Value, error)

The DictionaryFunc type is an adapter to allow the use of ordinary function as Dictionary mutator.

func (DictionaryFunc) Mutate

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

Mutate calls f(ctx, m).

type DomainFunc

type DomainFunc func(context.Context, *ent.DomainMutation) (ent.Value, error)

The DomainFunc type is an adapter to allow the use of ordinary function as Domain mutator.

func (DomainFunc) Mutate

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

Mutate calls f(ctx, m).

type DomainMembershipFunc

type DomainMembershipFunc func(context.Context, *ent.DomainMembershipMutation) (ent.Value, error)

The DomainMembershipFunc type is an adapter to allow the use of ordinary function as DomainMembership mutator.

func (DomainMembershipFunc) Mutate

Mutate calls f(ctx, m).

type DomainRelationFunc

type DomainRelationFunc func(context.Context, *ent.DomainRelationMutation) (ent.Value, error)

The DomainRelationFunc type is an adapter to allow the use of ordinary function as DomainRelation mutator.

func (DomainRelationFunc) Mutate

Mutate calls f(ctx, m).

type DomainTypeFunc

type DomainTypeFunc func(context.Context, *ent.DomainTypeMutation) (ent.Value, error)

The DomainTypeFunc type is an adapter to allow the use of ordinary function as DomainType mutator.

func (DomainTypeFunc) Mutate

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

Mutate calls f(ctx, m).

type InvitationTokenFunc

type InvitationTokenFunc func(context.Context, *ent.InvitationTokenMutation) (ent.Value, error)

The InvitationTokenFunc type is an adapter to allow the use of ordinary function as InvitationToken mutator.

func (InvitationTokenFunc) Mutate

Mutate calls f(ctx, m).

type MediaFolderFunc

type MediaFolderFunc func(context.Context, *ent.MediaFolderMutation) (ent.Value, error)

The MediaFolderFunc type is an adapter to allow the use of ordinary function as MediaFolder mutator.

func (MediaFolderFunc) Mutate

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

Mutate calls f(ctx, m).

type MediaFormatFunc

type MediaFormatFunc func(context.Context, *ent.MediaFormatMutation) (ent.Value, error)

The MediaFormatFunc type is an adapter to allow the use of ordinary function as MediaFormat mutator.

func (MediaFormatFunc) Mutate

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

Mutate calls f(ctx, m).

type MediaFunc

type MediaFunc func(context.Context, *ent.MediaMutation) (ent.Value, error)

The MediaFunc type is an adapter to allow the use of ordinary function as Media mutator.

func (MediaFunc) Mutate

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

Mutate calls f(ctx, m).

type MenuFunc func(context.Context, *ent.MenuMutation) (ent.Value, error)

The MenuFunc type is an adapter to allow the use of ordinary function as Menu mutator.

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

Mutate calls f(ctx, m).

type OperationLogFunc

type OperationLogFunc func(context.Context, *ent.OperationLogMutation) (ent.Value, error)

The OperationLogFunc type is an adapter to allow the use of ordinary function as OperationLog mutator.

func (OperationLogFunc) Mutate

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

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 OrganizationMemberFunc

type OrganizationMemberFunc func(context.Context, *ent.OrganizationMemberMutation) (ent.Value, error)

The OrganizationMemberFunc type is an adapter to allow the use of ordinary function as OrganizationMember mutator.

func (OrganizationMemberFunc) Mutate

Mutate calls f(ctx, m).

type PasswordResetTokenFunc

type PasswordResetTokenFunc func(context.Context, *ent.PasswordResetTokenMutation) (ent.Value, error)

The PasswordResetTokenFunc type is an adapter to allow the use of ordinary function as PasswordResetToken mutator.

func (PasswordResetTokenFunc) Mutate

Mutate calls f(ctx, m).

type PermissionFunc

type PermissionFunc func(context.Context, *ent.PermissionMutation) (ent.Value, error)

The PermissionFunc type is an adapter to allow the use of ordinary function as Permission mutator.

func (PermissionFunc) Mutate

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

Mutate calls f(ctx, m).

type PostFunc

type PostFunc func(context.Context, *ent.PostMutation) (ent.Value, error)

The PostFunc type is an adapter to allow the use of ordinary function as Post mutator.

func (PostFunc) Mutate

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

Mutate calls f(ctx, m).

type ResourceDomainBindingFunc

type ResourceDomainBindingFunc func(context.Context, *ent.ResourceDomainBindingMutation) (ent.Value, error)

The ResourceDomainBindingFunc type is an adapter to allow the use of ordinary function as ResourceDomainBinding mutator.

func (ResourceDomainBindingFunc) 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 RoleFunc

type RoleFunc func(context.Context, *ent.RoleMutation) (ent.Value, error)

The RoleFunc type is an adapter to allow the use of ordinary function as Role mutator.

func (RoleFunc) Mutate

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

type SystemConfigFunc func(context.Context, *ent.SystemConfigMutation) (ent.Value, error)

The SystemConfigFunc type is an adapter to allow the use of ordinary function as SystemConfig mutator.

func (SystemConfigFunc) Mutate

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

Mutate calls f(ctx, m).

type SystemErrorFunc

type SystemErrorFunc func(context.Context, *ent.SystemErrorMutation) (ent.Value, error)

The SystemErrorFunc type is an adapter to allow the use of ordinary function as SystemError mutator.

func (SystemErrorFunc) Mutate

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

type TenantUserFunc func(context.Context, *ent.TenantUserMutation) (ent.Value, error)

The TenantUserFunc type is an adapter to allow the use of ordinary function as TenantUser mutator.

func (TenantUserFunc) Mutate

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

Jump to

Keyboard shortcuts

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