ent: github.com/facebookincubator/ent/entc/integration/ent/hook Index | Files

package hook

import "github.com/facebookincubator/ent/entc/integration/ent/hook"

Index

Package Files

hook.go

func If Uses

func If(hk ent.Hook, cond Condition) ent.Hook

If executes the given hook under condition.

Hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))

func On Uses

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 Uses

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 Uses

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)

type CardFunc Uses

type CardFunc func(context.Context, *ent.CardMutation) (ent.Value, error)

The CardFunc type is an adapter to allow the use of ordinary function as Card mutator.

func (CardFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type Chain Uses

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 Uses

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

NewChain creates a new chain of hooks.

func (Chain) Append Uses

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 Uses

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 Uses

func (c Chain) Hook() ent.Hook

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

type CommentFunc Uses

type CommentFunc func(context.Context, *ent.CommentMutation) (ent.Value, error)

The CommentFunc type is an adapter to allow the use of ordinary function as Comment mutator.

func (CommentFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type Condition Uses

type Condition func(context.Context, ent.Mutation) bool

Condition is a hook condition function.

func And Uses

func And(first, second Condition, rest ...Condition) Condition

And groups conditions with the AND operator.

func HasAddedFields Uses

func HasAddedFields(field string, fields ...string) Condition

HasAddedFields is a condition validating `.AddedField` on fields.

func HasClearedFields Uses

func HasClearedFields(field string, fields ...string) Condition

HasClearedFields is a condition validating `.FieldCleared` on fields.

func HasFields Uses

func HasFields(field string, fields ...string) Condition

HasFields is a condition validating `.Field` on fields.

func HasOp Uses

func HasOp(op ent.Op) Condition

HasOp is a condition testing mutation operation.

func Not Uses

func Not(cond Condition) Condition

Not negates a given condition.

func Or Uses

func Or(first, second Condition, rest ...Condition) Condition

Or groups conditions with the OR operator.

type FieldTypeFunc Uses

type FieldTypeFunc func(context.Context, *ent.FieldTypeMutation) (ent.Value, error)

The FieldTypeFunc type is an adapter to allow the use of ordinary function as FieldType mutator.

func (FieldTypeFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type FileFunc Uses

type FileFunc func(context.Context, *ent.FileMutation) (ent.Value, error)

The FileFunc type is an adapter to allow the use of ordinary function as File mutator.

func (FileFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type FileTypeFunc Uses

type FileTypeFunc func(context.Context, *ent.FileTypeMutation) (ent.Value, error)

The FileTypeFunc type is an adapter to allow the use of ordinary function as FileType mutator.

func (FileTypeFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type GroupFunc Uses

type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)

The GroupFunc type is an adapter to allow the use of ordinary function as Group mutator.

func (GroupFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type GroupInfoFunc Uses

type GroupInfoFunc func(context.Context, *ent.GroupInfoMutation) (ent.Value, error)

The GroupInfoFunc type is an adapter to allow the use of ordinary function as GroupInfo mutator.

func (GroupInfoFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type ItemFunc Uses

type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)

The ItemFunc type is an adapter to allow the use of ordinary function as Item mutator.

func (ItemFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type NodeFunc Uses

type NodeFunc func(context.Context, *ent.NodeMutation) (ent.Value, error)

The NodeFunc type is an adapter to allow the use of ordinary function as Node mutator.

func (NodeFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type PetFunc Uses

type PetFunc func(context.Context, *ent.PetMutation) (ent.Value, error)

The PetFunc type is an adapter to allow the use of ordinary function as Pet mutator.

func (PetFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type SpecFunc Uses

type SpecFunc func(context.Context, *ent.SpecMutation) (ent.Value, error)

The SpecFunc type is an adapter to allow the use of ordinary function as Spec mutator.

func (SpecFunc) Mutate Uses

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

Mutate calls f(ctx, m).

type UserFunc Uses

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 Uses

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

Mutate calls f(ctx, m).

Package hook imports 3 packages (graph). Updated 2020-07-07. Refresh now. Tools for package owners.