hook

package
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: AGPL-3.0 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 AddonAssociationFunc added in v1.0.21

type AddonAssociationFunc func(context.Context, *ent.AddonAssociationMutation) (ent.Value, error)

The AddonAssociationFunc type is an adapter to allow the use of ordinary function as AddonAssociation mutator.

func (AddonAssociationFunc) Mutate added in v1.0.21

Mutate calls f(ctx, m).

type AddonFunc added in v1.0.21

type AddonFunc func(context.Context, *ent.AddonMutation) (ent.Value, error)

The AddonFunc type is an adapter to allow the use of ordinary function as Addon mutator.

func (AddonFunc) Mutate added in v1.0.21

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

Mutate calls f(ctx, m).

type AlertLogsFunc added in v1.0.29

type AlertLogsFunc func(context.Context, *ent.AlertLogsMutation) (ent.Value, error)

The AlertLogsFunc type is an adapter to allow the use of ordinary function as AlertLogs mutator.

func (AlertLogsFunc) Mutate added in v1.0.29

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

Mutate calls f(ctx, m).

type AuthFunc

type AuthFunc func(context.Context, *ent.AuthMutation) (ent.Value, error)

The AuthFunc type is an adapter to allow the use of ordinary function as Auth mutator.

func (AuthFunc) Mutate

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

Mutate calls f(ctx, m).

type BillingSequenceFunc

type BillingSequenceFunc func(context.Context, *ent.BillingSequenceMutation) (ent.Value, error)

The BillingSequenceFunc type is an adapter to allow the use of ordinary function as BillingSequence mutator.

func (BillingSequenceFunc) Mutate

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 added in v1.0.21

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 added in v1.0.21

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

Mutate calls f(ctx, m).

type CostsheetFunc added in v1.0.18

type CostsheetFunc func(context.Context, *ent.CostsheetMutation) (ent.Value, error)

The CostsheetFunc type is an adapter to allow the use of ordinary function as Costsheet mutator.

func (CostsheetFunc) Mutate added in v1.0.18

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

Mutate calls f(ctx, m).

type CouponApplicationFunc added in v1.0.21

type CouponApplicationFunc func(context.Context, *ent.CouponApplicationMutation) (ent.Value, error)

The CouponApplicationFunc type is an adapter to allow the use of ordinary function as CouponApplication mutator.

func (CouponApplicationFunc) Mutate added in v1.0.21

Mutate calls f(ctx, m).

type CouponAssociationFunc added in v1.0.21

type CouponAssociationFunc func(context.Context, *ent.CouponAssociationMutation) (ent.Value, error)

The CouponAssociationFunc type is an adapter to allow the use of ordinary function as CouponAssociation mutator.

func (CouponAssociationFunc) Mutate added in v1.0.21

Mutate calls f(ctx, m).

type CouponFunc added in v1.0.21

type CouponFunc func(context.Context, *ent.CouponMutation) (ent.Value, error)

The CouponFunc type is an adapter to allow the use of ordinary function as Coupon mutator.

func (CouponFunc) Mutate added in v1.0.21

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

Mutate calls f(ctx, m).

type CreditGrantApplicationFunc added in v1.0.18

type CreditGrantApplicationFunc func(context.Context, *ent.CreditGrantApplicationMutation) (ent.Value, error)

The CreditGrantApplicationFunc type is an adapter to allow the use of ordinary function as CreditGrantApplication mutator.

func (CreditGrantApplicationFunc) Mutate added in v1.0.18

Mutate calls f(ctx, m).

type CreditGrantFunc added in v1.0.18

type CreditGrantFunc func(context.Context, *ent.CreditGrantMutation) (ent.Value, error)

The CreditGrantFunc type is an adapter to allow the use of ordinary function as CreditGrant mutator.

func (CreditGrantFunc) Mutate added in v1.0.18

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

Mutate calls f(ctx, m).

type CreditNoteFunc added in v1.0.18

type CreditNoteFunc func(context.Context, *ent.CreditNoteMutation) (ent.Value, error)

The CreditNoteFunc type is an adapter to allow the use of ordinary function as CreditNote mutator.

func (CreditNoteFunc) Mutate added in v1.0.18

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

Mutate calls f(ctx, m).

type CreditNoteLineItemFunc added in v1.0.18

type CreditNoteLineItemFunc func(context.Context, *ent.CreditNoteLineItemMutation) (ent.Value, error)

The CreditNoteLineItemFunc type is an adapter to allow the use of ordinary function as CreditNoteLineItem mutator.

func (CreditNoteLineItemFunc) Mutate added in v1.0.18

Mutate calls f(ctx, m).

type CustomerFunc

type CustomerFunc func(context.Context, *ent.CustomerMutation) (ent.Value, error)

The CustomerFunc type is an adapter to allow the use of ordinary function as Customer mutator.

func (CustomerFunc) Mutate

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

Mutate calls f(ctx, m).

type EntitlementFunc

type EntitlementFunc func(context.Context, *ent.EntitlementMutation) (ent.Value, error)

The EntitlementFunc type is an adapter to allow the use of ordinary function as Entitlement mutator.

func (EntitlementFunc) Mutate

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

Mutate calls f(ctx, m).

type EntityIntegrationMappingFunc added in v1.0.21

type EntityIntegrationMappingFunc func(context.Context, *ent.EntityIntegrationMappingMutation) (ent.Value, error)

The EntityIntegrationMappingFunc type is an adapter to allow the use of ordinary function as EntityIntegrationMapping mutator.

func (EntityIntegrationMappingFunc) Mutate added in v1.0.21

Mutate calls f(ctx, m).

type EnvironmentFunc

type EnvironmentFunc func(context.Context, *ent.EnvironmentMutation) (ent.Value, error)

The EnvironmentFunc type is an adapter to allow the use of ordinary function as Environment mutator.

func (EnvironmentFunc) Mutate

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

Mutate calls f(ctx, m).

type FeatureFunc

type FeatureFunc func(context.Context, *ent.FeatureMutation) (ent.Value, error)

The FeatureFunc type is an adapter to allow the use of ordinary function as Feature mutator.

func (FeatureFunc) Mutate

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

Mutate calls f(ctx, m).

type GroupFunc added in v1.0.34

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 added in v1.0.34

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

Mutate calls f(ctx, m).

type InvoiceFunc

type InvoiceFunc func(context.Context, *ent.InvoiceMutation) (ent.Value, error)

The InvoiceFunc type is an adapter to allow the use of ordinary function as Invoice mutator.

func (InvoiceFunc) Mutate

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

Mutate calls f(ctx, m).

type InvoiceLineItemFunc

type InvoiceLineItemFunc func(context.Context, *ent.InvoiceLineItemMutation) (ent.Value, error)

The InvoiceLineItemFunc type is an adapter to allow the use of ordinary function as InvoiceLineItem mutator.

func (InvoiceLineItemFunc) Mutate

Mutate calls f(ctx, m).

type InvoiceSequenceFunc

type InvoiceSequenceFunc func(context.Context, *ent.InvoiceSequenceMutation) (ent.Value, error)

The InvoiceSequenceFunc type is an adapter to allow the use of ordinary function as InvoiceSequence mutator.

func (InvoiceSequenceFunc) Mutate

Mutate calls f(ctx, m).

type MeterFunc

type MeterFunc func(context.Context, *ent.MeterMutation) (ent.Value, error)

The MeterFunc type is an adapter to allow the use of ordinary function as Meter mutator.

func (MeterFunc) Mutate

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

Mutate calls f(ctx, m).

type PaymentAttemptFunc

type PaymentAttemptFunc func(context.Context, *ent.PaymentAttemptMutation) (ent.Value, error)

The PaymentAttemptFunc type is an adapter to allow the use of ordinary function as PaymentAttempt mutator.

func (PaymentAttemptFunc) Mutate

Mutate calls f(ctx, m).

type PaymentFunc

type PaymentFunc func(context.Context, *ent.PaymentMutation) (ent.Value, error)

The PaymentFunc type is an adapter to allow the use of ordinary function as Payment mutator.

func (PaymentFunc) Mutate

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

Mutate calls f(ctx, m).

type PlanFunc

type PlanFunc func(context.Context, *ent.PlanMutation) (ent.Value, error)

The PlanFunc type is an adapter to allow the use of ordinary function as Plan mutator.

func (PlanFunc) Mutate

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

Mutate calls f(ctx, m).

type PriceFunc

type PriceFunc func(context.Context, *ent.PriceMutation) (ent.Value, error)

The PriceFunc type is an adapter to allow the use of ordinary function as Price mutator.

func (PriceFunc) Mutate

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

Mutate calls f(ctx, m).

type PriceUnitFunc added in v1.0.21

type PriceUnitFunc func(context.Context, *ent.PriceUnitMutation) (ent.Value, error)

The PriceUnitFunc type is an adapter to allow the use of ordinary function as PriceUnit mutator.

func (PriceUnitFunc) Mutate added in v1.0.21

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

Mutate calls f(ctx, m).

type ScheduledTaskFunc added in v1.0.32

type ScheduledTaskFunc func(context.Context, *ent.ScheduledTaskMutation) (ent.Value, error)

The ScheduledTaskFunc type is an adapter to allow the use of ordinary function as ScheduledTask mutator.

func (ScheduledTaskFunc) Mutate added in v1.0.32

Mutate calls f(ctx, m).

type SecretFunc

type SecretFunc func(context.Context, *ent.SecretMutation) (ent.Value, error)

The SecretFunc type is an adapter to allow the use of ordinary function as Secret mutator.

func (SecretFunc) Mutate

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

Mutate calls f(ctx, m).

type SettingsFunc added in v1.0.22

type SettingsFunc func(context.Context, *ent.SettingsMutation) (ent.Value, error)

The SettingsFunc type is an adapter to allow the use of ordinary function as Settings mutator.

func (SettingsFunc) Mutate added in v1.0.22

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

Mutate calls f(ctx, m).

type SubscriptionFunc

type SubscriptionFunc func(context.Context, *ent.SubscriptionMutation) (ent.Value, error)

The SubscriptionFunc type is an adapter to allow the use of ordinary function as Subscription mutator.

func (SubscriptionFunc) Mutate

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

Mutate calls f(ctx, m).

type SubscriptionLineItemFunc

type SubscriptionLineItemFunc func(context.Context, *ent.SubscriptionLineItemMutation) (ent.Value, error)

The SubscriptionLineItemFunc type is an adapter to allow the use of ordinary function as SubscriptionLineItem mutator.

func (SubscriptionLineItemFunc) Mutate

Mutate calls f(ctx, m).

type SubscriptionPauseFunc

type SubscriptionPauseFunc func(context.Context, *ent.SubscriptionPauseMutation) (ent.Value, error)

The SubscriptionPauseFunc type is an adapter to allow the use of ordinary function as SubscriptionPause mutator.

func (SubscriptionPauseFunc) Mutate

Mutate calls f(ctx, m).

type SubscriptionScheduleFunc added in v1.0.18

type SubscriptionScheduleFunc func(context.Context, *ent.SubscriptionScheduleMutation) (ent.Value, error)

The SubscriptionScheduleFunc type is an adapter to allow the use of ordinary function as SubscriptionSchedule mutator.

func (SubscriptionScheduleFunc) Mutate added in v1.0.18

Mutate calls f(ctx, m).

type SubscriptionSchedulePhaseFunc added in v1.0.18

type SubscriptionSchedulePhaseFunc func(context.Context, *ent.SubscriptionSchedulePhaseMutation) (ent.Value, error)

The SubscriptionSchedulePhaseFunc type is an adapter to allow the use of ordinary function as SubscriptionSchedulePhase mutator.

func (SubscriptionSchedulePhaseFunc) Mutate added in v1.0.18

Mutate calls f(ctx, m).

type TaskFunc

type TaskFunc func(context.Context, *ent.TaskMutation) (ent.Value, error)

The TaskFunc type is an adapter to allow the use of ordinary function as Task mutator.

func (TaskFunc) Mutate

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

Mutate calls f(ctx, m).

type TaxAppliedFunc added in v1.0.21

type TaxAppliedFunc func(context.Context, *ent.TaxAppliedMutation) (ent.Value, error)

The TaxAppliedFunc type is an adapter to allow the use of ordinary function as TaxApplied mutator.

func (TaxAppliedFunc) Mutate added in v1.0.21

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

Mutate calls f(ctx, m).

type TaxAssociationFunc added in v1.0.21

type TaxAssociationFunc func(context.Context, *ent.TaxAssociationMutation) (ent.Value, error)

The TaxAssociationFunc type is an adapter to allow the use of ordinary function as TaxAssociation mutator.

func (TaxAssociationFunc) Mutate added in v1.0.21

Mutate calls f(ctx, m).

type TaxRateFunc added in v1.0.21

type TaxRateFunc func(context.Context, *ent.TaxRateMutation) (ent.Value, error)

The TaxRateFunc type is an adapter to allow the use of ordinary function as TaxRate mutator.

func (TaxRateFunc) Mutate added in v1.0.21

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

Mutate calls f(ctx, m).

type TenantFunc

type TenantFunc func(context.Context, *ent.TenantMutation) (ent.Value, error)

The TenantFunc type is an adapter to allow the use of ordinary function as Tenant mutator.

func (TenantFunc) Mutate

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

Mutate calls f(ctx, m).

type UserFunc

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

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

Mutate calls f(ctx, m).

type WalletFunc

type WalletFunc func(context.Context, *ent.WalletMutation) (ent.Value, error)

The WalletFunc type is an adapter to allow the use of ordinary function as Wallet mutator.

func (WalletFunc) Mutate

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

Mutate calls f(ctx, m).

type WalletTransactionFunc

type WalletTransactionFunc func(context.Context, *ent.WalletTransactionMutation) (ent.Value, error)

The WalletTransactionFunc type is an adapter to allow the use of ordinary function as WalletTransaction mutator.

func (WalletTransactionFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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