hook

package
v0.0.0-...-8b6722b Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 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 AssetClassFunc

type AssetClassFunc func(context.Context, *ent.AssetClassMutation) (ent.Value, error)

The AssetClassFunc type is an adapter to allow the use of ordinary function as AssetClass mutator.

func (AssetClassFunc) Mutate

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

Mutate calls f(ctx, m).

type AssetFunc

type AssetFunc func(context.Context, *ent.AssetMutation) (ent.Value, error)

The AssetFunc type is an adapter to allow the use of ordinary function as Asset mutator.

func (AssetFunc) Mutate

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

Mutate calls f(ctx, m).

type AuthRoleFunc

type AuthRoleFunc func(context.Context, *ent.AuthRoleMutation) (ent.Value, error)

The AuthRoleFunc type is an adapter to allow the use of ordinary function as AuthRole mutator.

func (AuthRoleFunc) Mutate

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

Mutate calls f(ctx, m).

type AuthTypeFunc

type AuthTypeFunc func(context.Context, *ent.AuthTypeMutation) (ent.Value, error)

The AuthTypeFunc type is an adapter to allow the use of ordinary function as AuthType mutator.

func (AuthTypeFunc) Mutate

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

Mutate calls f(ctx, m).

type BlockchainFunc

type BlockchainFunc func(context.Context, *ent.BlockchainMutation) (ent.Value, error)

The BlockchainFunc type is an adapter to allow the use of ordinary function as Blockchain mutator.

func (BlockchainFunc) Mutate

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

type ConnectionFunc func(context.Context, *ent.ConnectionMutation) (ent.Value, error)

The ConnectionFunc type is an adapter to allow the use of ordinary function as Connection mutator.

func (ConnectionFunc) Mutate

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

Mutate calls f(ctx, m).

type CryptocurrencyFunc

type CryptocurrencyFunc func(context.Context, *ent.CryptocurrencyMutation) (ent.Value, error)

The CryptocurrencyFunc type is an adapter to allow the use of ordinary function as Cryptocurrency mutator.

func (CryptocurrencyFunc) Mutate

Mutate calls f(ctx, m).

type DailyAssetPriceFunc

type DailyAssetPriceFunc func(context.Context, *ent.DailyAssetPriceMutation) (ent.Value, error)

The DailyAssetPriceFunc type is an adapter to allow the use of ordinary function as DailyAssetPrice mutator.

func (DailyAssetPriceFunc) Mutate

Mutate calls f(ctx, m).

type ExchangeFunc

type ExchangeFunc func(context.Context, *ent.ExchangeMutation) (ent.Value, error)

The ExchangeFunc type is an adapter to allow the use of ordinary function as Exchange mutator.

func (ExchangeFunc) Mutate

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

Mutate calls f(ctx, m).

type PortfolioFunc

type PortfolioFunc func(context.Context, *ent.PortfolioMutation) (ent.Value, error)

The PortfolioFunc type is an adapter to allow the use of ordinary function as Portfolio mutator.

func (PortfolioFunc) Mutate

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

Mutate calls f(ctx, m).

type SourceFunc

type SourceFunc func(context.Context, *ent.SourceMutation) (ent.Value, error)

The SourceFunc type is an adapter to allow the use of ordinary function as Source mutator.

func (SourceFunc) Mutate

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

Mutate calls f(ctx, m).

type SourceTypeFunc

type SourceTypeFunc func(context.Context, *ent.SourceTypeMutation) (ent.Value, error)

The SourceTypeFunc type is an adapter to allow the use of ordinary function as SourceType mutator.

func (SourceTypeFunc) Mutate

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

Mutate calls f(ctx, m).

type StaffAccountFunc

type StaffAccountFunc func(context.Context, *ent.StaffAccountMutation) (ent.Value, error)

The StaffAccountFunc type is an adapter to allow the use of ordinary function as StaffAccount mutator.

func (StaffAccountFunc) Mutate

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

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).

type TransactionTypeFunc

type TransactionTypeFunc func(context.Context, *ent.TransactionTypeMutation) (ent.Value, error)

The TransactionTypeFunc type is an adapter to allow the use of ordinary function as TransactionType mutator.

func (TransactionTypeFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL