hook

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 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 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 ProxyAdsFunc

type ProxyAdsFunc func(context.Context, *ent.ProxyAdsMutation) (ent.Value, error)

The ProxyAdsFunc type is an adapter to allow the use of ordinary function as ProxyAds mutator.

func (ProxyAdsFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyAnnouncementFunc

type ProxyAnnouncementFunc func(context.Context, *ent.ProxyAnnouncementMutation) (ent.Value, error)

The ProxyAnnouncementFunc type is an adapter to allow the use of ordinary function as ProxyAnnouncement mutator.

func (ProxyAnnouncementFunc) Mutate

Mutate calls f(ctx, m).

type ProxyAuthMethodFunc

type ProxyAuthMethodFunc func(context.Context, *ent.ProxyAuthMethodMutation) (ent.Value, error)

The ProxyAuthMethodFunc type is an adapter to allow the use of ordinary function as ProxyAuthMethod mutator.

func (ProxyAuthMethodFunc) Mutate

Mutate calls f(ctx, m).

type ProxyCouponFunc

type ProxyCouponFunc func(context.Context, *ent.ProxyCouponMutation) (ent.Value, error)

The ProxyCouponFunc type is an adapter to allow the use of ordinary function as ProxyCoupon mutator.

func (ProxyCouponFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyDocumentFunc

type ProxyDocumentFunc func(context.Context, *ent.ProxyDocumentMutation) (ent.Value, error)

The ProxyDocumentFunc type is an adapter to allow the use of ordinary function as ProxyDocument mutator.

func (ProxyDocumentFunc) Mutate

Mutate calls f(ctx, m).

type ProxyGroupHistoryDetailFunc

type ProxyGroupHistoryDetailFunc func(context.Context, *ent.ProxyGroupHistoryDetailMutation) (ent.Value, error)

The ProxyGroupHistoryDetailFunc type is an adapter to allow the use of ordinary function as ProxyGroupHistoryDetail mutator.

func (ProxyGroupHistoryDetailFunc) Mutate

Mutate calls f(ctx, m).

type ProxyGroupHistoryFunc

type ProxyGroupHistoryFunc func(context.Context, *ent.ProxyGroupHistoryMutation) (ent.Value, error)

The ProxyGroupHistoryFunc type is an adapter to allow the use of ordinary function as ProxyGroupHistory mutator.

func (ProxyGroupHistoryFunc) Mutate

Mutate calls f(ctx, m).

type ProxyNodeFunc

type ProxyNodeFunc func(context.Context, *ent.ProxyNodeMutation) (ent.Value, error)

The ProxyNodeFunc type is an adapter to allow the use of ordinary function as ProxyNode mutator.

func (ProxyNodeFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyOrderFunc

type ProxyOrderFunc func(context.Context, *ent.ProxyOrderMutation) (ent.Value, error)

The ProxyOrderFunc type is an adapter to allow the use of ordinary function as ProxyOrder mutator.

func (ProxyOrderFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyPaymentFunc

type ProxyPaymentFunc func(context.Context, *ent.ProxyPaymentMutation) (ent.Value, error)

The ProxyPaymentFunc type is an adapter to allow the use of ordinary function as ProxyPayment mutator.

func (ProxyPaymentFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyRedemptionCodeFunc

type ProxyRedemptionCodeFunc func(context.Context, *ent.ProxyRedemptionCodeMutation) (ent.Value, error)

The ProxyRedemptionCodeFunc type is an adapter to allow the use of ordinary function as ProxyRedemptionCode mutator.

func (ProxyRedemptionCodeFunc) Mutate

Mutate calls f(ctx, m).

type ProxyRedemptionRecordFunc

type ProxyRedemptionRecordFunc func(context.Context, *ent.ProxyRedemptionRecordMutation) (ent.Value, error)

The ProxyRedemptionRecordFunc type is an adapter to allow the use of ordinary function as ProxyRedemptionRecord mutator.

func (ProxyRedemptionRecordFunc) Mutate

Mutate calls f(ctx, m).

type ProxySchemaMigrationsFunc

type ProxySchemaMigrationsFunc func(context.Context, *ent.ProxySchemaMigrationsMutation) (ent.Value, error)

The ProxySchemaMigrationsFunc type is an adapter to allow the use of ordinary function as ProxySchemaMigrations mutator.

func (ProxySchemaMigrationsFunc) Mutate

Mutate calls f(ctx, m).

type ProxyServerFunc

type ProxyServerFunc func(context.Context, *ent.ProxyServerMutation) (ent.Value, error)

The ProxyServerFunc type is an adapter to allow the use of ordinary function as ProxyServer mutator.

func (ProxyServerFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyServerGroupFunc

type ProxyServerGroupFunc func(context.Context, *ent.ProxyServerGroupMutation) (ent.Value, error)

The ProxyServerGroupFunc type is an adapter to allow the use of ordinary function as ProxyServerGroup mutator.

func (ProxyServerGroupFunc) Mutate

Mutate calls f(ctx, m).

type ProxySubscribeApplicationFunc

type ProxySubscribeApplicationFunc func(context.Context, *ent.ProxySubscribeApplicationMutation) (ent.Value, error)

The ProxySubscribeApplicationFunc type is an adapter to allow the use of ordinary function as ProxySubscribeApplication mutator.

func (ProxySubscribeApplicationFunc) Mutate

Mutate calls f(ctx, m).

type ProxySubscribeCategoryFunc added in v1.0.9

type ProxySubscribeCategoryFunc func(context.Context, *ent.ProxySubscribeCategoryMutation) (ent.Value, error)

The ProxySubscribeCategoryFunc type is an adapter to allow the use of ordinary function as ProxySubscribeCategory mutator.

func (ProxySubscribeCategoryFunc) Mutate added in v1.0.9

Mutate calls f(ctx, m).

type ProxySubscribeFunc

type ProxySubscribeFunc func(context.Context, *ent.ProxySubscribeMutation) (ent.Value, error)

The ProxySubscribeFunc type is an adapter to allow the use of ordinary function as ProxySubscribe mutator.

func (ProxySubscribeFunc) Mutate

Mutate calls f(ctx, m).

type ProxySubscribeGroupFunc

type ProxySubscribeGroupFunc func(context.Context, *ent.ProxySubscribeGroupMutation) (ent.Value, error)

The ProxySubscribeGroupFunc type is an adapter to allow the use of ordinary function as ProxySubscribeGroup mutator.

func (ProxySubscribeGroupFunc) Mutate

Mutate calls f(ctx, m).

type ProxySubscribePriceOptionFunc added in v1.0.10

type ProxySubscribePriceOptionFunc func(context.Context, *ent.ProxySubscribePriceOptionMutation) (ent.Value, error)

The ProxySubscribePriceOptionFunc type is an adapter to allow the use of ordinary function as ProxySubscribePriceOption mutator.

func (ProxySubscribePriceOptionFunc) Mutate added in v1.0.10

Mutate calls f(ctx, m).

type ProxySystemFunc

type ProxySystemFunc func(context.Context, *ent.ProxySystemMutation) (ent.Value, error)

The ProxySystemFunc type is an adapter to allow the use of ordinary function as ProxySystem mutator.

func (ProxySystemFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxySystemLogFunc

type ProxySystemLogFunc func(context.Context, *ent.ProxySystemLogMutation) (ent.Value, error)

The ProxySystemLogFunc type is an adapter to allow the use of ordinary function as ProxySystemLog mutator.

func (ProxySystemLogFunc) Mutate

Mutate calls f(ctx, m).

type ProxyTaskFunc

type ProxyTaskFunc func(context.Context, *ent.ProxyTaskMutation) (ent.Value, error)

The ProxyTaskFunc type is an adapter to allow the use of ordinary function as ProxyTask mutator.

func (ProxyTaskFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyTicketFollowFunc

type ProxyTicketFollowFunc func(context.Context, *ent.ProxyTicketFollowMutation) (ent.Value, error)

The ProxyTicketFollowFunc type is an adapter to allow the use of ordinary function as ProxyTicketFollow mutator.

func (ProxyTicketFollowFunc) Mutate

Mutate calls f(ctx, m).

type ProxyTicketFunc

type ProxyTicketFunc func(context.Context, *ent.ProxyTicketMutation) (ent.Value, error)

The ProxyTicketFunc type is an adapter to allow the use of ordinary function as ProxyTicket mutator.

func (ProxyTicketFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyTrafficLogFunc

type ProxyTrafficLogFunc func(context.Context, *ent.ProxyTrafficLogMutation) (ent.Value, error)

The ProxyTrafficLogFunc type is an adapter to allow the use of ordinary function as ProxyTrafficLog mutator.

func (ProxyTrafficLogFunc) Mutate

Mutate calls f(ctx, m).

type ProxyUserAuthMethodFunc

type ProxyUserAuthMethodFunc func(context.Context, *ent.ProxyUserAuthMethodMutation) (ent.Value, error)

The ProxyUserAuthMethodFunc type is an adapter to allow the use of ordinary function as ProxyUserAuthMethod mutator.

func (ProxyUserAuthMethodFunc) Mutate

Mutate calls f(ctx, m).

type ProxyUserDeviceFunc

type ProxyUserDeviceFunc func(context.Context, *ent.ProxyUserDeviceMutation) (ent.Value, error)

The ProxyUserDeviceFunc type is an adapter to allow the use of ordinary function as ProxyUserDevice mutator.

func (ProxyUserDeviceFunc) Mutate

Mutate calls f(ctx, m).

type ProxyUserDeviceOnlineRecordFunc

type ProxyUserDeviceOnlineRecordFunc func(context.Context, *ent.ProxyUserDeviceOnlineRecordMutation) (ent.Value, error)

The ProxyUserDeviceOnlineRecordFunc type is an adapter to allow the use of ordinary function as ProxyUserDeviceOnlineRecord mutator.

func (ProxyUserDeviceOnlineRecordFunc) Mutate

Mutate calls f(ctx, m).

type ProxyUserFunc

type ProxyUserFunc func(context.Context, *ent.ProxyUserMutation) (ent.Value, error)

The ProxyUserFunc type is an adapter to allow the use of ordinary function as ProxyUser mutator.

func (ProxyUserFunc) Mutate

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

Mutate calls f(ctx, m).

type ProxyUserSubscribeFunc

type ProxyUserSubscribeFunc func(context.Context, *ent.ProxyUserSubscribeMutation) (ent.Value, error)

The ProxyUserSubscribeFunc type is an adapter to allow the use of ordinary function as ProxyUserSubscribe mutator.

func (ProxyUserSubscribeFunc) Mutate

Mutate calls f(ctx, m).

type ProxyUserWithdrawalFunc

type ProxyUserWithdrawalFunc func(context.Context, *ent.ProxyUserWithdrawalMutation) (ent.Value, error)

The ProxyUserWithdrawalFunc type is an adapter to allow the use of ordinary function as ProxyUserWithdrawal mutator.

func (ProxyUserWithdrawalFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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