hook

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 7, 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 AccountFunc

type AccountFunc func(context.Context, *ent.AccountMutation) (ent.Value, error)

The AccountFunc type is an adapter to allow the use of ordinary function as Account mutator.

func (AccountFunc) Mutate

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

Mutate calls f(ctx, m).

type BankFunc

type BankFunc func(context.Context, *ent.BankMutation) (ent.Value, error)

The BankFunc type is an adapter to allow the use of ordinary function as Bank mutator.

func (BankFunc) Mutate

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

Mutate calls f(ctx, m).

type BinaryItemFunc

type BinaryItemFunc func(context.Context, *ent.BinaryItemMutation) (ent.Value, error)

The BinaryItemFunc type is an adapter to allow the use of ordinary function as BinaryItem mutator.

func (BinaryItemFunc) Mutate

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

Mutate calls f(ctx, m).

type BranchFunc

type BranchFunc func(context.Context, *ent.BranchMutation) (ent.Value, error)

The BranchFunc type is an adapter to allow the use of ordinary function as Branch mutator.

func (BranchFunc) Mutate

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

Mutate calls f(ctx, m).

type CardFunc

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

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

Mutate calls f(ctx, m).

type CardNetworkFunc

type CardNetworkFunc func(context.Context, *ent.CardNetworkMutation) (ent.Value, error)

The CardNetworkFunc type is an adapter to allow the use of ordinary function as CardNetwork mutator.

func (CardNetworkFunc) Mutate

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

type EntityAddressFunc func(context.Context, *ent.EntityAddressMutation) (ent.Value, error)

The EntityAddressFunc type is an adapter to allow the use of ordinary function as EntityAddress mutator.

func (EntityAddressFunc) Mutate

Mutate calls f(ctx, m).

type EntityContactPointFunc

type EntityContactPointFunc func(context.Context, *ent.EntityContactPointMutation) (ent.Value, error)

The EntityContactPointFunc type is an adapter to allow the use of ordinary function as EntityContactPoint mutator.

func (EntityContactPointFunc) Mutate

Mutate calls f(ctx, m).

type EntityFunc

type EntityFunc func(context.Context, *ent.EntityMutation) (ent.Value, error)

The EntityFunc type is an adapter to allow the use of ordinary function as Entity mutator.

func (EntityFunc) Mutate

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

Mutate calls f(ctx, m).

type EntityTaxInformationFunc

type EntityTaxInformationFunc func(context.Context, *ent.EntityTaxInformationMutation) (ent.Value, error)

The EntityTaxInformationFunc type is an adapter to allow the use of ordinary function as EntityTaxInformation mutator.

func (EntityTaxInformationFunc) Mutate

Mutate calls f(ctx, m).

type PreferenceFunc

type PreferenceFunc func(context.Context, *ent.PreferenceMutation) (ent.Value, error)

The PreferenceFunc type is an adapter to allow the use of ordinary function as Preference mutator.

func (PreferenceFunc) Mutate

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

Mutate calls f(ctx, m).

type ProductFunc

type ProductFunc func(context.Context, *ent.ProductMutation) (ent.Value, error)

The ProductFunc type is an adapter to allow the use of ordinary function as Product mutator.

func (ProductFunc) Mutate

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

Mutate calls f(ctx, m).

type RoutingNumberFunc

type RoutingNumberFunc func(context.Context, *ent.RoutingNumberMutation) (ent.Value, error)

The RoutingNumberFunc type is an adapter to allow the use of ordinary function as RoutingNumber mutator.

func (RoutingNumberFunc) Mutate

Mutate calls f(ctx, m).

type TransactionFunc

type TransactionFunc func(context.Context, *ent.TransactionMutation) (ent.Value, error)

The TransactionFunc type is an adapter to allow the use of ordinary function as Transaction mutator.

func (TransactionFunc) Mutate

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