hook

package
v0.0.0-...-c5055fb Latest Latest
Warning

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

Go to latest
Published: Sep 7, 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 AbilityBonusFunc

type AbilityBonusFunc func(context.Context, *ent.AbilityBonusMutation) (ent.Value, error)

The AbilityBonusFunc type is an adapter to allow the use of ordinary function as AbilityBonus mutator.

func (AbilityBonusFunc) Mutate

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

Mutate calls f(ctx, m).

type AbilityScoreFunc

type AbilityScoreFunc func(context.Context, *ent.AbilityScoreMutation) (ent.Value, error)

The AbilityScoreFunc type is an adapter to allow the use of ordinary function as AbilityScore mutator.

func (AbilityScoreFunc) Mutate

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

Mutate calls f(ctx, m).

type ArmorClassFunc

type ArmorClassFunc func(context.Context, *ent.ArmorClassMutation) (ent.Value, error)

The ArmorClassFunc type is an adapter to allow the use of ordinary function as ArmorClass mutator.

func (ArmorClassFunc) Mutate

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

Mutate calls f(ctx, m).

type ArmorFunc

type ArmorFunc func(context.Context, *ent.ArmorMutation) (ent.Value, error)

The ArmorFunc type is an adapter to allow the use of ordinary function as Armor mutator.

func (ArmorFunc) Mutate

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

type ClassEquipmentFunc func(context.Context, *ent.ClassEquipmentMutation) (ent.Value, error)

The ClassEquipmentFunc type is an adapter to allow the use of ordinary function as ClassEquipment mutator.

func (ClassEquipmentFunc) Mutate

Mutate calls f(ctx, m).

type ClassFunc

type ClassFunc func(context.Context, *ent.ClassMutation) (ent.Value, error)

The ClassFunc type is an adapter to allow the use of ordinary function as Class mutator.

func (ClassFunc) Mutate

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

Mutate calls f(ctx, m).

type CoinFunc

type CoinFunc func(context.Context, *ent.CoinMutation) (ent.Value, error)

The CoinFunc type is an adapter to allow the use of ordinary function as Coin mutator.

func (CoinFunc) Mutate

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

Mutate calls f(ctx, m).

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 DamageTypeFunc

type DamageTypeFunc func(context.Context, *ent.DamageTypeMutation) (ent.Value, error)

The DamageTypeFunc type is an adapter to allow the use of ordinary function as DamageType mutator.

func (DamageTypeFunc) Mutate

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

Mutate calls f(ctx, m).

type EquipmentCategoryFunc

type EquipmentCategoryFunc func(context.Context, *ent.EquipmentCategoryMutation) (ent.Value, error)

The EquipmentCategoryFunc type is an adapter to allow the use of ordinary function as EquipmentCategory mutator.

func (EquipmentCategoryFunc) Mutate

Mutate calls f(ctx, m).

type EquipmentChoiceFunc

type EquipmentChoiceFunc func(context.Context, *ent.EquipmentChoiceMutation) (ent.Value, error)

The EquipmentChoiceFunc type is an adapter to allow the use of ordinary function as EquipmentChoice mutator.

func (EquipmentChoiceFunc) Mutate

Mutate calls f(ctx, m).

type EquipmentCostFunc

type EquipmentCostFunc func(context.Context, *ent.EquipmentCostMutation) (ent.Value, error)

The EquipmentCostFunc type is an adapter to allow the use of ordinary function as EquipmentCost mutator.

func (EquipmentCostFunc) Mutate

Mutate calls f(ctx, m).

type EquipmentFunc

type EquipmentFunc func(context.Context, *ent.EquipmentMutation) (ent.Value, error)

The EquipmentFunc type is an adapter to allow the use of ordinary function as Equipment mutator.

func (EquipmentFunc) Mutate

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

Mutate calls f(ctx, m).

type GearFunc

type GearFunc func(context.Context, *ent.GearMutation) (ent.Value, error)

The GearFunc type is an adapter to allow the use of ordinary function as Gear mutator.

func (GearFunc) Mutate

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

Mutate calls f(ctx, m).

type LanguageFunc

type LanguageFunc func(context.Context, *ent.LanguageMutation) (ent.Value, error)

The LanguageFunc type is an adapter to allow the use of ordinary function as Language mutator.

func (LanguageFunc) Mutate

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

Mutate calls f(ctx, m).

type MagicSchoolFunc

type MagicSchoolFunc func(context.Context, *ent.MagicSchoolMutation) (ent.Value, error)

The MagicSchoolFunc type is an adapter to allow the use of ordinary function as MagicSchool mutator.

func (MagicSchoolFunc) Mutate

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

Mutate calls f(ctx, m).

type ProficiencyChoiceFunc

type ProficiencyChoiceFunc func(context.Context, *ent.ProficiencyChoiceMutation) (ent.Value, error)

The ProficiencyChoiceFunc type is an adapter to allow the use of ordinary function as ProficiencyChoice mutator.

func (ProficiencyChoiceFunc) Mutate

Mutate calls f(ctx, m).

type ProficiencyFunc

type ProficiencyFunc func(context.Context, *ent.ProficiencyMutation) (ent.Value, error)

The ProficiencyFunc type is an adapter to allow the use of ordinary function as Proficiency mutator.

func (ProficiencyFunc) Mutate

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

Mutate calls f(ctx, m).

type RaceFunc

type RaceFunc func(context.Context, *ent.RaceMutation) (ent.Value, error)

The RaceFunc type is an adapter to allow the use of ordinary function as Race mutator.

func (RaceFunc) Mutate

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

Mutate calls f(ctx, m).

type RuleFunc

type RuleFunc func(context.Context, *ent.RuleMutation) (ent.Value, error)

The RuleFunc type is an adapter to allow the use of ordinary function as Rule mutator.

func (RuleFunc) Mutate

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

Mutate calls f(ctx, m).

type RuleSectionFunc

type RuleSectionFunc func(context.Context, *ent.RuleSectionMutation) (ent.Value, error)

The RuleSectionFunc type is an adapter to allow the use of ordinary function as RuleSection mutator.

func (RuleSectionFunc) Mutate

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

Mutate calls f(ctx, m).

type SkillFunc

type SkillFunc func(context.Context, *ent.SkillMutation) (ent.Value, error)

The SkillFunc type is an adapter to allow the use of ordinary function as Skill mutator.

func (SkillFunc) Mutate

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

Mutate calls f(ctx, m).

type SubraceFunc

type SubraceFunc func(context.Context, *ent.SubraceMutation) (ent.Value, error)

The SubraceFunc type is an adapter to allow the use of ordinary function as Subrace mutator.

func (SubraceFunc) Mutate

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

Mutate calls f(ctx, m).

type ToolFunc

type ToolFunc func(context.Context, *ent.ToolMutation) (ent.Value, error)

The ToolFunc type is an adapter to allow the use of ordinary function as Tool mutator.

func (ToolFunc) Mutate

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

Mutate calls f(ctx, m).

type TraitFunc

type TraitFunc func(context.Context, *ent.TraitMutation) (ent.Value, error)

The TraitFunc type is an adapter to allow the use of ordinary function as Trait mutator.

func (TraitFunc) Mutate

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

Mutate calls f(ctx, m).

type VehicleFunc

type VehicleFunc func(context.Context, *ent.VehicleMutation) (ent.Value, error)

The VehicleFunc type is an adapter to allow the use of ordinary function as Vehicle mutator.

func (VehicleFunc) Mutate

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

Mutate calls f(ctx, m).

type WeaponDamageFunc

type WeaponDamageFunc func(context.Context, *ent.WeaponDamageMutation) (ent.Value, error)

The WeaponDamageFunc type is an adapter to allow the use of ordinary function as WeaponDamage mutator.

func (WeaponDamageFunc) Mutate

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

Mutate calls f(ctx, m).

type WeaponFunc

type WeaponFunc func(context.Context, *ent.WeaponMutation) (ent.Value, error)

The WeaponFunc type is an adapter to allow the use of ordinary function as Weapon mutator.

func (WeaponFunc) Mutate

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

Mutate calls f(ctx, m).

type WeaponPropertyFunc

type WeaponPropertyFunc func(context.Context, *ent.WeaponPropertyMutation) (ent.Value, error)

The WeaponPropertyFunc type is an adapter to allow the use of ordinary function as WeaponProperty mutator.

func (WeaponPropertyFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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