hook

package
v0.0.0-...-04b2c92 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 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 AppActionFunc

type AppActionFunc func(context.Context, *ent.AppActionMutation) (ent.Value, error)

The AppActionFunc type is an adapter to allow the use of ordinary function as AppAction mutator.

func (AppActionFunc) Mutate

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

Mutate calls f(ctx, m).

type AppDictFunc

type AppDictFunc func(context.Context, *ent.AppDictMutation) (ent.Value, error)

The AppDictFunc type is an adapter to allow the use of ordinary function as AppDict mutator.

func (AppDictFunc) Mutate

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

Mutate calls f(ctx, m).

type AppDictItemFunc

type AppDictItemFunc func(context.Context, *ent.AppDictItemMutation) (ent.Value, error)

The AppDictItemFunc type is an adapter to allow the use of ordinary function as AppDictItem mutator.

func (AppDictItemFunc) Mutate

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

type AppMenuFunc func(context.Context, *ent.AppMenuMutation) (ent.Value, error)

The AppMenuFunc type is an adapter to allow the use of ordinary function as AppMenu mutator.

func (AppMenuFunc) Mutate

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

Mutate calls f(ctx, m).

type AppPolicyFunc

type AppPolicyFunc func(context.Context, *ent.AppPolicyMutation) (ent.Value, error)

The AppPolicyFunc type is an adapter to allow the use of ordinary function as AppPolicy mutator.

func (AppPolicyFunc) Mutate

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

Mutate calls f(ctx, m).

type AppResFunc

type AppResFunc func(context.Context, *ent.AppResMutation) (ent.Value, error)

The AppResFunc type is an adapter to allow the use of ordinary function as AppRes mutator.

func (AppResFunc) Mutate

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

Mutate calls f(ctx, m).

type AppRoleFunc

type AppRoleFunc func(context.Context, *ent.AppRoleMutation) (ent.Value, error)

The AppRoleFunc type is an adapter to allow the use of ordinary function as AppRole mutator.

func (AppRoleFunc) Mutate

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

Mutate calls f(ctx, m).

type AppRolePolicyFunc

type AppRolePolicyFunc func(context.Context, *ent.AppRolePolicyMutation) (ent.Value, error)

The AppRolePolicyFunc type is an adapter to allow the use of ordinary function as AppRolePolicy mutator.

func (AppRolePolicyFunc) 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 FileIdentityFunc

type FileIdentityFunc func(context.Context, *ent.FileIdentityMutation) (ent.Value, error)

The FileIdentityFunc type is an adapter to allow the use of ordinary function as FileIdentity mutator.

func (FileIdentityFunc) Mutate

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

Mutate calls f(ctx, m).

type FileSourceFunc

type FileSourceFunc func(context.Context, *ent.FileSourceMutation) (ent.Value, error)

The FileSourceFunc type is an adapter to allow the use of ordinary function as FileSource mutator.

func (FileSourceFunc) Mutate

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

type OrgAppFunc func(context.Context, *ent.OrgAppMutation) (ent.Value, error)

The OrgAppFunc type is an adapter to allow the use of ordinary function as OrgApp mutator.

func (OrgAppFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgFunc

type OrgFunc func(context.Context, *ent.OrgMutation) (ent.Value, error)

The OrgFunc type is an adapter to allow the use of ordinary function as Org mutator.

func (OrgFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgPolicyFunc

type OrgPolicyFunc func(context.Context, *ent.OrgPolicyMutation) (ent.Value, error)

The OrgPolicyFunc type is an adapter to allow the use of ordinary function as OrgPolicy mutator.

func (OrgPolicyFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgRoleFunc

type OrgRoleFunc func(context.Context, *ent.OrgRoleMutation) (ent.Value, error)

The OrgRoleFunc type is an adapter to allow the use of ordinary function as OrgRole mutator.

func (OrgRoleFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgRoleUserFunc

type OrgRoleUserFunc func(context.Context, *ent.OrgRoleUserMutation) (ent.Value, error)

The OrgRoleUserFunc type is an adapter to allow the use of ordinary function as OrgRoleUser mutator.

func (OrgRoleUserFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgUserFunc

type OrgUserFunc func(context.Context, *ent.OrgUserMutation) (ent.Value, error)

The OrgUserFunc type is an adapter to allow the use of ordinary function as OrgUser mutator.

func (OrgUserFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgUserPreferenceFunc

type OrgUserPreferenceFunc func(context.Context, *ent.OrgUserPreferenceMutation) (ent.Value, error)

The OrgUserPreferenceFunc type is an adapter to allow the use of ordinary function as OrgUserPreference mutator.

func (OrgUserPreferenceFunc) 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 UserDeviceFunc

type UserDeviceFunc func(context.Context, *ent.UserDeviceMutation) (ent.Value, error)

The UserDeviceFunc type is an adapter to allow the use of ordinary function as UserDevice mutator.

func (UserDeviceFunc) Mutate

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

type UserLoginProfileFunc func(context.Context, *ent.UserLoginProfileMutation) (ent.Value, error)

The UserLoginProfileFunc type is an adapter to allow the use of ordinary function as UserLoginProfile mutator.

func (UserLoginProfileFunc) Mutate

Mutate calls f(ctx, m).

type UserPasswordFunc

type UserPasswordFunc func(context.Context, *ent.UserPasswordMutation) (ent.Value, error)

The UserPasswordFunc type is an adapter to allow the use of ordinary function as UserPassword mutator.

func (UserPasswordFunc) Mutate

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