hook

package
v1.0.0-beta.187 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.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) db.Hook

FixedError is a hook returning a fixed error.

func If

func If(hk db.Hook, cond Condition) db.Hook

If executes the given hook under condition.

hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))

func On

func On(hk db.Hook, op db.Op) db.Hook

On executes the given hook only for the given operation.

hook.On(Log, db.Delete|db.Create)

func Reject

func Reject(op db.Op) db.Hook

Reject returns a hook that rejects all operations that match op.

func (T) Hooks() []db.Hook {
	return []db.Hook{
		Reject(db.Delete|db.Update),
	}
}

func Unless

func Unless(hk db.Hook, op db.Op) db.Hook

Unless skips the given hook only for the given operation.

hook.Unless(Log, db.Update|db.UpdateOne)

Types

type AppCustomerFunc

type AppCustomerFunc func(context.Context, *db.AppCustomerMutation) (db.Value, error)

The AppCustomerFunc type is an adapter to allow the use of ordinary function as AppCustomer mutator.

func (AppCustomerFunc) Mutate

func (f AppCustomerFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type AppFunc

type AppFunc func(context.Context, *db.AppMutation) (db.Value, error)

The AppFunc type is an adapter to allow the use of ordinary function as App mutator.

func (AppFunc) Mutate

func (f AppFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type AppStripeCustomerFunc

type AppStripeCustomerFunc func(context.Context, *db.AppStripeCustomerMutation) (db.Value, error)

The AppStripeCustomerFunc type is an adapter to allow the use of ordinary function as AppStripeCustomer mutator.

func (AppStripeCustomerFunc) Mutate

Mutate calls f(ctx, m).

type AppStripeFunc

type AppStripeFunc func(context.Context, *db.AppStripeMutation) (db.Value, error)

The AppStripeFunc type is an adapter to allow the use of ordinary function as AppStripe mutator.

func (AppStripeFunc) Mutate

func (f AppStripeFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type BalanceSnapshotFunc

type BalanceSnapshotFunc func(context.Context, *db.BalanceSnapshotMutation) (db.Value, error)

The BalanceSnapshotFunc type is an adapter to allow the use of ordinary function as BalanceSnapshot mutator.

func (BalanceSnapshotFunc) Mutate

Mutate calls f(ctx, m).

type BillingCustomerOverrideFunc

type BillingCustomerOverrideFunc func(context.Context, *db.BillingCustomerOverrideMutation) (db.Value, error)

The BillingCustomerOverrideFunc type is an adapter to allow the use of ordinary function as BillingCustomerOverride mutator.

func (BillingCustomerOverrideFunc) Mutate

Mutate calls f(ctx, m).

type BillingInvoiceFlatFeeLineConfigFunc

type BillingInvoiceFlatFeeLineConfigFunc func(context.Context, *db.BillingInvoiceFlatFeeLineConfigMutation) (db.Value, error)

The BillingInvoiceFlatFeeLineConfigFunc type is an adapter to allow the use of ordinary function as BillingInvoiceFlatFeeLineConfig mutator.

func (BillingInvoiceFlatFeeLineConfigFunc) Mutate

Mutate calls f(ctx, m).

type BillingInvoiceFunc

type BillingInvoiceFunc func(context.Context, *db.BillingInvoiceMutation) (db.Value, error)

The BillingInvoiceFunc type is an adapter to allow the use of ordinary function as BillingInvoice mutator.

func (BillingInvoiceFunc) Mutate

func (f BillingInvoiceFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type BillingInvoiceLineDiscountFunc

type BillingInvoiceLineDiscountFunc func(context.Context, *db.BillingInvoiceLineDiscountMutation) (db.Value, error)

The BillingInvoiceLineDiscountFunc type is an adapter to allow the use of ordinary function as BillingInvoiceLineDiscount mutator.

func (BillingInvoiceLineDiscountFunc) Mutate

Mutate calls f(ctx, m).

type BillingInvoiceLineFunc

type BillingInvoiceLineFunc func(context.Context, *db.BillingInvoiceLineMutation) (db.Value, error)

The BillingInvoiceLineFunc type is an adapter to allow the use of ordinary function as BillingInvoiceLine mutator.

func (BillingInvoiceLineFunc) Mutate

Mutate calls f(ctx, m).

type BillingInvoiceUsageBasedLineConfigFunc

type BillingInvoiceUsageBasedLineConfigFunc func(context.Context, *db.BillingInvoiceUsageBasedLineConfigMutation) (db.Value, error)

The BillingInvoiceUsageBasedLineConfigFunc type is an adapter to allow the use of ordinary function as BillingInvoiceUsageBasedLineConfig mutator.

func (BillingInvoiceUsageBasedLineConfigFunc) Mutate

Mutate calls f(ctx, m).

type BillingInvoiceValidationIssueFunc

type BillingInvoiceValidationIssueFunc func(context.Context, *db.BillingInvoiceValidationIssueMutation) (db.Value, error)

The BillingInvoiceValidationIssueFunc type is an adapter to allow the use of ordinary function as BillingInvoiceValidationIssue mutator.

func (BillingInvoiceValidationIssueFunc) Mutate

Mutate calls f(ctx, m).

type BillingProfileFunc

type BillingProfileFunc func(context.Context, *db.BillingProfileMutation) (db.Value, error)

The BillingProfileFunc type is an adapter to allow the use of ordinary function as BillingProfile mutator.

func (BillingProfileFunc) Mutate

func (f BillingProfileFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type BillingWorkflowConfigFunc

type BillingWorkflowConfigFunc func(context.Context, *db.BillingWorkflowConfigMutation) (db.Value, error)

The BillingWorkflowConfigFunc type is an adapter to allow the use of ordinary function as BillingWorkflowConfig mutator.

func (BillingWorkflowConfigFunc) 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 ...db.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

func (c Chain) Append(hooks ...db.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() db.Hook

Hook chains the list of hooks and returns the final hook.

type Condition

type Condition func(context.Context, db.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 db.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, *db.CustomerMutation) (db.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 db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type CustomerSubjectsFunc

type CustomerSubjectsFunc func(context.Context, *db.CustomerSubjectsMutation) (db.Value, error)

The CustomerSubjectsFunc type is an adapter to allow the use of ordinary function as CustomerSubjects mutator.

func (CustomerSubjectsFunc) Mutate

Mutate calls f(ctx, m).

type EntitlementFunc

type EntitlementFunc func(context.Context, *db.EntitlementMutation) (db.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 db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type FeatureFunc

type FeatureFunc func(context.Context, *db.FeatureMutation) (db.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 db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type GrantFunc

type GrantFunc func(context.Context, *db.GrantMutation) (db.Value, error)

The GrantFunc type is an adapter to allow the use of ordinary function as Grant mutator.

func (GrantFunc) Mutate

func (f GrantFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type NotificationChannelFunc

type NotificationChannelFunc func(context.Context, *db.NotificationChannelMutation) (db.Value, error)

The NotificationChannelFunc type is an adapter to allow the use of ordinary function as NotificationChannel mutator.

func (NotificationChannelFunc) Mutate

Mutate calls f(ctx, m).

type NotificationEventDeliveryStatusFunc

type NotificationEventDeliveryStatusFunc func(context.Context, *db.NotificationEventDeliveryStatusMutation) (db.Value, error)

The NotificationEventDeliveryStatusFunc type is an adapter to allow the use of ordinary function as NotificationEventDeliveryStatus mutator.

func (NotificationEventDeliveryStatusFunc) Mutate

Mutate calls f(ctx, m).

type NotificationEventFunc

type NotificationEventFunc func(context.Context, *db.NotificationEventMutation) (db.Value, error)

The NotificationEventFunc type is an adapter to allow the use of ordinary function as NotificationEvent mutator.

func (NotificationEventFunc) Mutate

Mutate calls f(ctx, m).

type NotificationRuleFunc

type NotificationRuleFunc func(context.Context, *db.NotificationRuleMutation) (db.Value, error)

The NotificationRuleFunc type is an adapter to allow the use of ordinary function as NotificationRule mutator.

func (NotificationRuleFunc) Mutate

Mutate calls f(ctx, m).

type PlanFunc

type PlanFunc func(context.Context, *db.PlanMutation) (db.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 db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type PlanPhaseFunc

type PlanPhaseFunc func(context.Context, *db.PlanPhaseMutation) (db.Value, error)

The PlanPhaseFunc type is an adapter to allow the use of ordinary function as PlanPhase mutator.

func (PlanPhaseFunc) Mutate

func (f PlanPhaseFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type PlanRateCardFunc

type PlanRateCardFunc func(context.Context, *db.PlanRateCardMutation) (db.Value, error)

The PlanRateCardFunc type is an adapter to allow the use of ordinary function as PlanRateCard mutator.

func (PlanRateCardFunc) Mutate

func (f PlanRateCardFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type SubscriptionFunc

type SubscriptionFunc func(context.Context, *db.SubscriptionMutation) (db.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 db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

type SubscriptionItemFunc

type SubscriptionItemFunc func(context.Context, *db.SubscriptionItemMutation) (db.Value, error)

The SubscriptionItemFunc type is an adapter to allow the use of ordinary function as SubscriptionItem mutator.

func (SubscriptionItemFunc) Mutate

Mutate calls f(ctx, m).

type SubscriptionPhaseFunc

type SubscriptionPhaseFunc func(context.Context, *db.SubscriptionPhaseMutation) (db.Value, error)

The SubscriptionPhaseFunc type is an adapter to allow the use of ordinary function as SubscriptionPhase mutator.

func (SubscriptionPhaseFunc) Mutate

Mutate calls f(ctx, m).

type UsageResetFunc

type UsageResetFunc func(context.Context, *db.UsageResetMutation) (db.Value, error)

The UsageResetFunc type is an adapter to allow the use of ordinary function as UsageReset mutator.

func (UsageResetFunc) Mutate

func (f UsageResetFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error)

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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