hook

package
v0.0.0-...-6edac6f Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 ActionFunc

type ActionFunc func(context.Context, *ent.ActionMutation) (ent.Value, error)

The ActionFunc type is an adapter to allow the use of ordinary function as Action mutator.

func (ActionFunc) Mutate

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

Mutate calls f(ctx, m).

type AliasFunc

type AliasFunc func(context.Context, *ent.AliasMutation) (ent.Value, error)

The AliasFunc type is an adapter to allow the use of ordinary function as Alias mutator.

func (AliasFunc) Mutate

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

Mutate calls f(ctx, m).

type AppFunc

type AppFunc func(context.Context, *ent.AppMutation) (ent.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 ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type BrowserFunc

type BrowserFunc func(context.Context, *ent.BrowserMutation) (ent.Value, error)

The BrowserFunc type is an adapter to allow the use of ordinary function as Browser mutator.

func (BrowserFunc) Mutate

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

Mutate calls f(ctx, m).

type CampaignFunc

type CampaignFunc func(context.Context, *ent.CampaignMutation) (ent.Value, error)

The CampaignFunc type is an adapter to allow the use of ordinary function as Campaign mutator.

func (CampaignFunc) Mutate

func (f CampaignFunc) 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 ConnectivityFunc

type ConnectivityFunc func(context.Context, *ent.ConnectivityMutation) (ent.Value, error)

The ConnectivityFunc type is an adapter to allow the use of ordinary function as Connectivity mutator.

func (ConnectivityFunc) Mutate

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

Mutate calls f(ctx, m).

type DeviceFunc

type DeviceFunc func(context.Context, *ent.DeviceMutation) (ent.Value, error)

The DeviceFunc type is an adapter to allow the use of ordinary function as Device mutator.

func (DeviceFunc) Mutate

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

Mutate calls f(ctx, m).

type EventFunc

type EventFunc func(context.Context, *ent.EventMutation) (ent.Value, error)

The EventFunc type is an adapter to allow the use of ordinary function as Event mutator.

func (EventFunc) Mutate

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

Mutate calls f(ctx, m).

type ExtraFunc

type ExtraFunc func(context.Context, *ent.ExtraMutation) (ent.Value, error)

The ExtraFunc type is an adapter to allow the use of ordinary function as Extra mutator.

func (ExtraFunc) Mutate

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

Mutate calls f(ctx, m).

type GroupFunc

type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)

The GroupFunc type is an adapter to allow the use of ordinary function as Group mutator.

func (GroupFunc) Mutate

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

Mutate calls f(ctx, m).

type LibraryFunc

type LibraryFunc func(context.Context, *ent.LibraryMutation) (ent.Value, error)

The LibraryFunc type is an adapter to allow the use of ordinary function as Library mutator.

func (LibraryFunc) Mutate

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

Mutate calls f(ctx, m).

type LocationFunc

type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error)

The LocationFunc type is an adapter to allow the use of ordinary function as Location mutator.

func (LocationFunc) Mutate

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

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 OSContextFunc

type OSContextFunc func(context.Context, *ent.OSContextMutation) (ent.Value, error)

The OSContextFunc type is an adapter to allow the use of ordinary function as OSContext mutator.

func (OSContextFunc) Mutate

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

Mutate calls f(ctx, m).

type PageFunc

type PageFunc func(context.Context, *ent.PageMutation) (ent.Value, error)

The PageFunc type is an adapter to allow the use of ordinary function as Page mutator.

func (PageFunc) Mutate

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

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 ScreenFunc

type ScreenFunc func(context.Context, *ent.ScreenMutation) (ent.Value, error)

The ScreenFunc type is an adapter to allow the use of ordinary function as Screen mutator.

func (ScreenFunc) Mutate

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

Mutate calls f(ctx, m).

type SessionFunc

type SessionFunc func(context.Context, *ent.SessionMutation) (ent.Value, error)

The SessionFunc type is an adapter to allow the use of ordinary function as Session mutator.

func (SessionFunc) Mutate

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

Mutate calls f(ctx, m).

type TimingFunc

type TimingFunc func(context.Context, *ent.TimingMutation) (ent.Value, error)

The TimingFunc type is an adapter to allow the use of ordinary function as Timing mutator.

func (TimingFunc) Mutate

func (f TimingFunc) 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 ViewportFunc

type ViewportFunc func(context.Context, *ent.ViewportMutation) (ent.Value, error)

The ViewportFunc type is an adapter to allow the use of ordinary function as Viewport mutator.

func (ViewportFunc) Mutate

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