hook

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 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 BarGroupFunc

type BarGroupFunc func(context.Context, *ent.BarGroupMutation) (ent.Value, error)

The BarGroupFunc type is an adapter to allow the use of ordinary function as BarGroup mutator.

func (BarGroupFunc) Mutate

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

Mutate calls f(ctx, m).

type BarRecordFunc

type BarRecordFunc func(context.Context, *ent.BarRecordMutation) (ent.Value, error)

The BarRecordFunc type is an adapter to allow the use of ordinary function as BarRecord mutator.

func (BarRecordFunc) Mutate

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

Mutate calls f(ctx, m).

type BarTimeRangeFunc

type BarTimeRangeFunc func(context.Context, *ent.BarTimeRangeMutation) (ent.Value, error)

The BarTimeRangeFunc type is an adapter to allow the use of ordinary function as BarTimeRange mutator.

func (BarTimeRangeFunc) Mutate

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

type DataSourceFunc func(context.Context, *ent.DataSourceMutation) (ent.Value, error)

The DataSourceFunc type is an adapter to allow the use of ordinary function as DataSource mutator.

func (DataSourceFunc) Mutate

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

Mutate calls f(ctx, m).

type DividendFunc

type DividendFunc func(context.Context, *ent.DividendMutation) (ent.Value, error)

The DividendFunc type is an adapter to allow the use of ordinary function as Dividend mutator.

func (DividendFunc) Mutate

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

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 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 FinancialFunc

type FinancialFunc func(context.Context, *ent.FinancialMutation) (ent.Value, error)

The FinancialFunc type is an adapter to allow the use of ordinary function as Financial mutator.

func (FinancialFunc) Mutate

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

Mutate calls f(ctx, m).

type IntervalFunc

type IntervalFunc func(context.Context, *ent.IntervalMutation) (ent.Value, error)

The IntervalFunc type is an adapter to allow the use of ordinary function as Interval mutator.

func (IntervalFunc) Mutate

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

Mutate calls f(ctx, m).

type MarketHoursFunc

type MarketHoursFunc func(context.Context, *ent.MarketHoursMutation) (ent.Value, error)

The MarketHoursFunc type is an adapter to allow the use of ordinary function as MarketHours mutator.

func (MarketHoursFunc) Mutate

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

Mutate calls f(ctx, m).

type MarketInfoFunc

type MarketInfoFunc func(context.Context, *ent.MarketInfoMutation) (ent.Value, error)

The MarketInfoFunc type is an adapter to allow the use of ordinary function as MarketInfo mutator.

func (MarketInfoFunc) Mutate

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

Mutate calls f(ctx, m).

type SplitFunc

type SplitFunc func(context.Context, *ent.SplitMutation) (ent.Value, error)

The SplitFunc type is an adapter to allow the use of ordinary function as Split mutator.

func (SplitFunc) Mutate

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

Mutate calls f(ctx, m).

type TradeConditionFunc

type TradeConditionFunc func(context.Context, *ent.TradeConditionMutation) (ent.Value, error)

The TradeConditionFunc type is an adapter to allow the use of ordinary function as TradeCondition mutator.

func (TradeConditionFunc) Mutate

Mutate calls f(ctx, m).

type TradeCorrectionFunc

type TradeCorrectionFunc func(context.Context, *ent.TradeCorrectionMutation) (ent.Value, error)

The TradeCorrectionFunc type is an adapter to allow the use of ordinary function as TradeCorrection mutator.

func (TradeCorrectionFunc) Mutate

Mutate calls f(ctx, m).

type TradeRecordFunc

type TradeRecordFunc func(context.Context, *ent.TradeRecordMutation) (ent.Value, error)

The TradeRecordFunc type is an adapter to allow the use of ordinary function as TradeRecord mutator.

func (TradeRecordFunc) Mutate

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

Mutate calls f(ctx, m).

type TradeTimeRangeFunc

type TradeTimeRangeFunc func(context.Context, *ent.TradeTimeRangeMutation) (ent.Value, error)

The TradeTimeRangeFunc type is an adapter to allow the use of ordinary function as TradeTimeRange mutator.

func (TradeTimeRangeFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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