hook

package
v0.2.0 Latest Latest
Warning

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

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

type APIKeyFunc func(context.Context, *ent.APIKeyMutation) (ent.Value, error)

The APIKeyFunc type is an adapter to allow the use of ordinary function as APIKey mutator.

func (APIKeyFunc) Mutate

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

Mutate calls f(ctx, m).

type BeneficialOwnerFunc

type BeneficialOwnerFunc func(context.Context, *ent.BeneficialOwnerMutation) (ent.Value, error)

The BeneficialOwnerFunc type is an adapter to allow the use of ordinary function as BeneficialOwner mutator.

func (BeneficialOwnerFunc) 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 FiatCurrencyFunc

type FiatCurrencyFunc func(context.Context, *ent.FiatCurrencyMutation) (ent.Value, error)

The FiatCurrencyFunc type is an adapter to allow the use of ordinary function as FiatCurrency mutator.

func (FiatCurrencyFunc) Mutate

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

Mutate calls f(ctx, m).

type IdentityVerificationRequestFunc

type IdentityVerificationRequestFunc func(context.Context, *ent.IdentityVerificationRequestMutation) (ent.Value, error)

The IdentityVerificationRequestFunc type is an adapter to allow the use of ordinary function as IdentityVerificationRequest mutator.

func (IdentityVerificationRequestFunc) Mutate

Mutate calls f(ctx, m).

type InstitutionFunc

type InstitutionFunc func(context.Context, *ent.InstitutionMutation) (ent.Value, error)

The InstitutionFunc type is an adapter to allow the use of ordinary function as Institution mutator.

func (InstitutionFunc) Mutate

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

Mutate calls f(ctx, m).

type KYBProfileFunc

type KYBProfileFunc func(context.Context, *ent.KYBProfileMutation) (ent.Value, error)

The KYBProfileFunc type is an adapter to allow the use of ordinary function as KYBProfile mutator.

func (KYBProfileFunc) Mutate

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

Mutate calls f(ctx, m).

type LinkedAddressFunc

type LinkedAddressFunc func(context.Context, *ent.LinkedAddressMutation) (ent.Value, error)

The LinkedAddressFunc type is an adapter to allow the use of ordinary function as LinkedAddress mutator.

func (LinkedAddressFunc) Mutate

Mutate calls f(ctx, m).

type LockOrderFulfillmentFunc

type LockOrderFulfillmentFunc func(context.Context, *ent.LockOrderFulfillmentMutation) (ent.Value, error)

The LockOrderFulfillmentFunc type is an adapter to allow the use of ordinary function as LockOrderFulfillment mutator.

func (LockOrderFulfillmentFunc) Mutate

Mutate calls f(ctx, m).

type LockPaymentOrderFunc

type LockPaymentOrderFunc func(context.Context, *ent.LockPaymentOrderMutation) (ent.Value, error)

The LockPaymentOrderFunc type is an adapter to allow the use of ordinary function as LockPaymentOrder mutator.

func (LockPaymentOrderFunc) Mutate

Mutate calls f(ctx, m).

type NetworkFunc

type NetworkFunc func(context.Context, *ent.NetworkMutation) (ent.Value, error)

The NetworkFunc type is an adapter to allow the use of ordinary function as Network mutator.

func (NetworkFunc) Mutate

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

Mutate calls f(ctx, m).

type PaymentOrderFunc

type PaymentOrderFunc func(context.Context, *ent.PaymentOrderMutation) (ent.Value, error)

The PaymentOrderFunc type is an adapter to allow the use of ordinary function as PaymentOrder mutator.

func (PaymentOrderFunc) Mutate

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

Mutate calls f(ctx, m).

type PaymentOrderRecipientFunc

type PaymentOrderRecipientFunc func(context.Context, *ent.PaymentOrderRecipientMutation) (ent.Value, error)

The PaymentOrderRecipientFunc type is an adapter to allow the use of ordinary function as PaymentOrderRecipient mutator.

func (PaymentOrderRecipientFunc) Mutate

Mutate calls f(ctx, m).

type PaymentWebhookFunc

type PaymentWebhookFunc func(context.Context, *ent.PaymentWebhookMutation) (ent.Value, error)

The PaymentWebhookFunc type is an adapter to allow the use of ordinary function as PaymentWebhook mutator.

func (PaymentWebhookFunc) Mutate

Mutate calls f(ctx, m).

type ProviderCurrenciesFunc added in v0.0.2

type ProviderCurrenciesFunc func(context.Context, *ent.ProviderCurrenciesMutation) (ent.Value, error)

The ProviderCurrenciesFunc type is an adapter to allow the use of ordinary function as ProviderCurrencies mutator.

func (ProviderCurrenciesFunc) Mutate added in v0.0.2

Mutate calls f(ctx, m).

type ProviderOrderTokenFunc

type ProviderOrderTokenFunc func(context.Context, *ent.ProviderOrderTokenMutation) (ent.Value, error)

The ProviderOrderTokenFunc type is an adapter to allow the use of ordinary function as ProviderOrderToken mutator.

func (ProviderOrderTokenFunc) Mutate

Mutate calls f(ctx, m).

type ProviderProfileFunc

type ProviderProfileFunc func(context.Context, *ent.ProviderProfileMutation) (ent.Value, error)

The ProviderProfileFunc type is an adapter to allow the use of ordinary function as ProviderProfile mutator.

func (ProviderProfileFunc) Mutate

Mutate calls f(ctx, m).

type ProviderRatingFunc

type ProviderRatingFunc func(context.Context, *ent.ProviderRatingMutation) (ent.Value, error)

The ProviderRatingFunc type is an adapter to allow the use of ordinary function as ProviderRating mutator.

func (ProviderRatingFunc) Mutate

Mutate calls f(ctx, m).

type ProvisionBucketFunc

type ProvisionBucketFunc func(context.Context, *ent.ProvisionBucketMutation) (ent.Value, error)

The ProvisionBucketFunc type is an adapter to allow the use of ordinary function as ProvisionBucket mutator.

func (ProvisionBucketFunc) Mutate

Mutate calls f(ctx, m).

type ReceiveAddressFunc

type ReceiveAddressFunc func(context.Context, *ent.ReceiveAddressMutation) (ent.Value, error)

The ReceiveAddressFunc type is an adapter to allow the use of ordinary function as ReceiveAddress mutator.

func (ReceiveAddressFunc) Mutate

Mutate calls f(ctx, m).

type SenderOrderTokenFunc

type SenderOrderTokenFunc func(context.Context, *ent.SenderOrderTokenMutation) (ent.Value, error)

The SenderOrderTokenFunc type is an adapter to allow the use of ordinary function as SenderOrderToken mutator.

func (SenderOrderTokenFunc) Mutate

Mutate calls f(ctx, m).

type SenderProfileFunc

type SenderProfileFunc func(context.Context, *ent.SenderProfileMutation) (ent.Value, error)

The SenderProfileFunc type is an adapter to allow the use of ordinary function as SenderProfile mutator.

func (SenderProfileFunc) Mutate

Mutate calls f(ctx, m).

type TokenFunc

type TokenFunc func(context.Context, *ent.TokenMutation) (ent.Value, error)

The TokenFunc type is an adapter to allow the use of ordinary function as Token mutator.

func (TokenFunc) Mutate

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

Mutate calls f(ctx, m).

type TransactionLogFunc

type TransactionLogFunc func(context.Context, *ent.TransactionLogMutation) (ent.Value, error)

The TransactionLogFunc type is an adapter to allow the use of ordinary function as TransactionLog mutator.

func (TransactionLogFunc) Mutate

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 VerificationTokenFunc

type VerificationTokenFunc func(context.Context, *ent.VerificationTokenMutation) (ent.Value, error)

The VerificationTokenFunc type is an adapter to allow the use of ordinary function as VerificationToken mutator.

func (VerificationTokenFunc) Mutate

Mutate calls f(ctx, m).

type WebhookRetryAttemptFunc

type WebhookRetryAttemptFunc func(context.Context, *ent.WebhookRetryAttemptMutation) (ent.Value, error)

The WebhookRetryAttemptFunc type is an adapter to allow the use of ordinary function as WebhookRetryAttempt mutator.

func (WebhookRetryAttemptFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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