hook

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 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 ChatHistoriesFunc

type ChatHistoriesFunc func(context.Context, *ent.ChatHistoriesMutation) (ent.Value, error)

The ChatHistoriesFunc type is an adapter to allow the use of ordinary function as ChatHistories mutator.

func (ChatHistoriesFunc) Mutate

Mutate calls f(ctx, m).

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 FeedbackChatHistoriesRecapsReactionsFunc added in v0.19.0

type FeedbackChatHistoriesRecapsReactionsFunc func(context.Context, *ent.FeedbackChatHistoriesRecapsReactionsMutation) (ent.Value, error)

The FeedbackChatHistoriesRecapsReactionsFunc type is an adapter to allow the use of ordinary function as FeedbackChatHistoriesRecapsReactions mutator.

func (FeedbackChatHistoriesRecapsReactionsFunc) Mutate added in v0.19.0

Mutate calls f(ctx, m).

type FeedbackSummarizationsReactionsFunc added in v0.19.0

type FeedbackSummarizationsReactionsFunc func(context.Context, *ent.FeedbackSummarizationsReactionsMutation) (ent.Value, error)

The FeedbackSummarizationsReactionsFunc type is an adapter to allow the use of ordinary function as FeedbackSummarizationsReactions mutator.

func (FeedbackSummarizationsReactionsFunc) Mutate added in v0.19.0

Mutate calls f(ctx, m).

type LogChatHistoriesRecapFunc

type LogChatHistoriesRecapFunc func(context.Context, *ent.LogChatHistoriesRecapMutation) (ent.Value, error)

The LogChatHistoriesRecapFunc type is an adapter to allow the use of ordinary function as LogChatHistoriesRecap mutator.

func (LogChatHistoriesRecapFunc) Mutate

Mutate calls f(ctx, m).

type LogSummarizationsFunc

type LogSummarizationsFunc func(context.Context, *ent.LogSummarizationsMutation) (ent.Value, error)

The LogSummarizationsFunc type is an adapter to allow the use of ordinary function as LogSummarizations mutator.

func (LogSummarizationsFunc) Mutate

Mutate calls f(ctx, m).

type MetricOpenAIChatCompletionTokenUsageFunc

type MetricOpenAIChatCompletionTokenUsageFunc func(context.Context, *ent.MetricOpenAIChatCompletionTokenUsageMutation) (ent.Value, error)

The MetricOpenAIChatCompletionTokenUsageFunc type is an adapter to allow the use of ordinary function as MetricOpenAIChatCompletionTokenUsage mutator.

func (MetricOpenAIChatCompletionTokenUsageFunc) Mutate

Mutate calls f(ctx, m).

type SlackOAuthCredentialsFunc

type SlackOAuthCredentialsFunc func(context.Context, *ent.SlackOAuthCredentialsMutation) (ent.Value, error)

The SlackOAuthCredentialsFunc type is an adapter to allow the use of ordinary function as SlackOAuthCredentials mutator.

func (SlackOAuthCredentialsFunc) Mutate

Mutate calls f(ctx, m).

type TelegramChatAutoRecapsSubscribersFunc added in v0.14.0

type TelegramChatAutoRecapsSubscribersFunc func(context.Context, *ent.TelegramChatAutoRecapsSubscribersMutation) (ent.Value, error)

The TelegramChatAutoRecapsSubscribersFunc type is an adapter to allow the use of ordinary function as TelegramChatAutoRecapsSubscribers mutator.

func (TelegramChatAutoRecapsSubscribersFunc) Mutate added in v0.14.0

Mutate calls f(ctx, m).

type TelegramChatFeatureFlagsFunc

type TelegramChatFeatureFlagsFunc func(context.Context, *ent.TelegramChatFeatureFlagsMutation) (ent.Value, error)

The TelegramChatFeatureFlagsFunc type is an adapter to allow the use of ordinary function as TelegramChatFeatureFlags mutator.

func (TelegramChatFeatureFlagsFunc) Mutate

Mutate calls f(ctx, m).

type TelegramChatRecapsOptionsFunc added in v0.14.0

type TelegramChatRecapsOptionsFunc func(context.Context, *ent.TelegramChatRecapsOptionsMutation) (ent.Value, error)

The TelegramChatRecapsOptionsFunc type is an adapter to allow the use of ordinary function as TelegramChatRecapsOptions mutator.

func (TelegramChatRecapsOptionsFunc) Mutate added in v0.14.0

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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