hook

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func On

func On(hk ent.Hook, op ent.Op) ent.Hook

On executes the given hook only of 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),
	}
}

Types

type Chain added in v0.1.5

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 added in v0.1.5

func NewChain(hooks ...ent.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append added in v0.1.5

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 added in v0.1.5

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 added in v0.1.5

func (c Chain) Hook() ent.Hook

Hook chains the list of hooks and returns the final hook.

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