hook

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 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 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 SysDictFunc

type SysDictFunc func(context.Context, *ent.SysDictMutation) (ent.Value, error)

The SysDictFunc type is an adapter to allow the use of ordinary function as SysDict mutator.

func (SysDictFunc) Mutate

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

Mutate calls f(ctx, m).

type SysDictItemFunc

type SysDictItemFunc func(context.Context, *ent.SysDictItemMutation) (ent.Value, error)

The SysDictItemFunc type is an adapter to allow the use of ordinary function as SysDictItem mutator.

func (SysDictItemFunc) Mutate

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

Mutate calls f(ctx, m).

type SysJwtBlockFunc

type SysJwtBlockFunc func(context.Context, *ent.SysJwtBlockMutation) (ent.Value, error)

The SysJwtBlockFunc type is an adapter to allow the use of ordinary function as SysJwtBlock mutator.

func (SysJwtBlockFunc) Mutate

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

Mutate calls f(ctx, m).

type SysLoggingFunc

type SysLoggingFunc func(context.Context, *ent.SysLoggingMutation) (ent.Value, error)

The SysLoggingFunc type is an adapter to allow the use of ordinary function as SysLogging mutator.

func (SysLoggingFunc) Mutate

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

Mutate calls f(ctx, m).

type SysMenuActionFunc

type SysMenuActionFunc func(context.Context, *ent.SysMenuActionMutation) (ent.Value, error)

The SysMenuActionFunc type is an adapter to allow the use of ordinary function as SysMenuAction mutator.

func (SysMenuActionFunc) Mutate

Mutate calls f(ctx, m).

type SysMenuActionResourceFunc

type SysMenuActionResourceFunc func(context.Context, *ent.SysMenuActionResourceMutation) (ent.Value, error)

The SysMenuActionResourceFunc type is an adapter to allow the use of ordinary function as SysMenuActionResource mutator.

func (SysMenuActionResourceFunc) Mutate

Mutate calls f(ctx, m).

type SysMenuFunc

type SysMenuFunc func(context.Context, *ent.SysMenuMutation) (ent.Value, error)

The SysMenuFunc type is an adapter to allow the use of ordinary function as SysMenu mutator.

func (SysMenuFunc) Mutate

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

Mutate calls f(ctx, m).

type SysRoleFunc

type SysRoleFunc func(context.Context, *ent.SysRoleMutation) (ent.Value, error)

The SysRoleFunc type is an adapter to allow the use of ordinary function as SysRole mutator.

func (SysRoleFunc) Mutate

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

Mutate calls f(ctx, m).

type SysRoleMenuFunc

type SysRoleMenuFunc func(context.Context, *ent.SysRoleMenuMutation) (ent.Value, error)

The SysRoleMenuFunc type is an adapter to allow the use of ordinary function as SysRoleMenu mutator.

func (SysRoleMenuFunc) Mutate

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

Mutate calls f(ctx, m).

type SysUserFunc

type SysUserFunc func(context.Context, *ent.SysUserMutation) (ent.Value, error)

The SysUserFunc type is an adapter to allow the use of ordinary function as SysUser mutator.

func (SysUserFunc) Mutate

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

Mutate calls f(ctx, m).

type SysUserRoleFunc

type SysUserRoleFunc func(context.Context, *ent.SysUserRoleMutation) (ent.Value, error)

The SysUserRoleFunc type is an adapter to allow the use of ordinary function as SysUserRole mutator.

func (SysUserRoleFunc) Mutate

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

Mutate calls f(ctx, m).

type XxxDemoFunc

type XxxDemoFunc func(context.Context, *ent.XxxDemoMutation) (ent.Value, error)

The XxxDemoFunc type is an adapter to allow the use of ordinary function as XxxDemo mutator.

func (XxxDemoFunc) Mutate

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