hook

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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 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 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 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 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 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 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 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 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