hook

package
v0.135.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 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) 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 APITokenFunc

type APITokenFunc func(context.Context, *ent.APITokenMutation) (ent.Value, error)

The APITokenFunc type is an adapter to allow the use of ordinary function as APIToken mutator.

func (APITokenFunc) Mutate

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

Mutate calls f(ctx, m).

type CASBackendFunc

type CASBackendFunc func(context.Context, *ent.CASBackendMutation) (ent.Value, error)

The CASBackendFunc type is an adapter to allow the use of ordinary function as CASBackend mutator.

func (CASBackendFunc) Mutate

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

Mutate calls f(ctx, m).

type CASMappingFunc

type CASMappingFunc func(context.Context, *ent.CASMappingMutation) (ent.Value, error)

The CASMappingFunc type is an adapter to allow the use of ordinary function as CASMapping mutator.

func (CASMappingFunc) Mutate

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

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 IntegrationAttachmentFunc

type IntegrationAttachmentFunc func(context.Context, *ent.IntegrationAttachmentMutation) (ent.Value, error)

The IntegrationAttachmentFunc type is an adapter to allow the use of ordinary function as IntegrationAttachment mutator.

func (IntegrationAttachmentFunc) Mutate

Mutate calls f(ctx, m).

type IntegrationFunc

type IntegrationFunc func(context.Context, *ent.IntegrationMutation) (ent.Value, error)

The IntegrationFunc type is an adapter to allow the use of ordinary function as Integration mutator.

func (IntegrationFunc) Mutate

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

Mutate calls f(ctx, m).

type MembershipFunc

type MembershipFunc func(context.Context, *ent.MembershipMutation) (ent.Value, error)

The MembershipFunc type is an adapter to allow the use of ordinary function as Membership mutator.

func (MembershipFunc) Mutate

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

Mutate calls f(ctx, m).

type OrgInvitationFunc

type OrgInvitationFunc func(context.Context, *ent.OrgInvitationMutation) (ent.Value, error)

The OrgInvitationFunc type is an adapter to allow the use of ordinary function as OrgInvitation mutator.

func (OrgInvitationFunc) Mutate

Mutate calls f(ctx, m).

type OrganizationFunc

type OrganizationFunc func(context.Context, *ent.OrganizationMutation) (ent.Value, error)

The OrganizationFunc type is an adapter to allow the use of ordinary function as Organization mutator.

func (OrganizationFunc) Mutate

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

Mutate calls f(ctx, m).

type ProjectFunc added in v0.97.4

type ProjectFunc func(context.Context, *ent.ProjectMutation) (ent.Value, error)

The ProjectFunc type is an adapter to allow the use of ordinary function as Project mutator.

func (ProjectFunc) Mutate added in v0.97.4

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

Mutate calls f(ctx, m).

type ProjectVersionFunc added in v0.97.5

type ProjectVersionFunc func(context.Context, *ent.ProjectVersionMutation) (ent.Value, error)

The ProjectVersionFunc type is an adapter to allow the use of ordinary function as ProjectVersion mutator.

func (ProjectVersionFunc) Mutate added in v0.97.5

Mutate calls f(ctx, m).

type ReferrerFunc

type ReferrerFunc func(context.Context, *ent.ReferrerMutation) (ent.Value, error)

The ReferrerFunc type is an adapter to allow the use of ordinary function as Referrer mutator.

func (ReferrerFunc) Mutate

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

Mutate calls f(ctx, m).

type RobotAccountFunc

type RobotAccountFunc func(context.Context, *ent.RobotAccountMutation) (ent.Value, error)

The RobotAccountFunc type is an adapter to allow the use of ordinary function as RobotAccount mutator.

func (RobotAccountFunc) Mutate

func (f RobotAccountFunc) 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 WorkflowContractFunc

type WorkflowContractFunc func(context.Context, *ent.WorkflowContractMutation) (ent.Value, error)

The WorkflowContractFunc type is an adapter to allow the use of ordinary function as WorkflowContract mutator.

func (WorkflowContractFunc) Mutate

Mutate calls f(ctx, m).

type WorkflowContractVersionFunc

type WorkflowContractVersionFunc func(context.Context, *ent.WorkflowContractVersionMutation) (ent.Value, error)

The WorkflowContractVersionFunc type is an adapter to allow the use of ordinary function as WorkflowContractVersion mutator.

func (WorkflowContractVersionFunc) Mutate

Mutate calls f(ctx, m).

type WorkflowFunc

type WorkflowFunc func(context.Context, *ent.WorkflowMutation) (ent.Value, error)

The WorkflowFunc type is an adapter to allow the use of ordinary function as Workflow mutator.

func (WorkflowFunc) Mutate

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

Mutate calls f(ctx, m).

type WorkflowRunFunc

type WorkflowRunFunc func(context.Context, *ent.WorkflowRunMutation) (ent.Value, error)

The WorkflowRunFunc type is an adapter to allow the use of ordinary function as WorkflowRun mutator.

func (WorkflowRunFunc) Mutate

func (f WorkflowRunFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.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