hook

package
v0.0.0-...-910bef7 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: GPL-3.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 ActorsFunc

type ActorsFunc func(context.Context, *ent.ActorsMutation) (ent.Value, error)

The ActorsFunc type is an adapter to allow the use of ordinary function as Actors mutator.

func (ActorsFunc) Mutate

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

Mutate calls f(ctx, m).

type AlbumsFunc

type AlbumsFunc func(context.Context, *ent.AlbumsMutation) (ent.Value, error)

The AlbumsFunc type is an adapter to allow the use of ordinary function as Albums mutator.

func (AlbumsFunc) Mutate

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

Mutate calls f(ctx, m).

type ArtistsFunc

type ArtistsFunc func(context.Context, *ent.ArtistsMutation) (ent.Value, error)

The ArtistsFunc type is an adapter to allow the use of ordinary function as Artists mutator.

func (ArtistsFunc) Mutate

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

Mutate calls f(ctx, m).

type AudiobooksFunc

type AudiobooksFunc func(context.Context, *ent.AudiobooksMutation) (ent.Value, error)

The AudiobooksFunc type is an adapter to allow the use of ordinary function as Audiobooks mutator.

func (AudiobooksFunc) Mutate

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

Mutate calls f(ctx, m).

type CategorysFunc

type CategorysFunc func(context.Context, *ent.CategorysMutation) (ent.Value, error)

The CategorysFunc type is an adapter to allow the use of ordinary function as Categorys mutator.

func (CategorysFunc) Mutate

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

type DevicesFunc func(context.Context, *ent.DevicesMutation) (ent.Value, error)

The DevicesFunc type is an adapter to allow the use of ordinary function as Devices mutator.

func (DevicesFunc) Mutate

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

Mutate calls f(ctx, m).

type DirectorsFunc

type DirectorsFunc func(context.Context, *ent.DirectorsMutation) (ent.Value, error)

The DirectorsFunc type is an adapter to allow the use of ordinary function as Directors mutator.

func (DirectorsFunc) Mutate

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

Mutate calls f(ctx, m).

type FilesFunc

type FilesFunc func(context.Context, *ent.FilesMutation) (ent.Value, error)

The FilesFunc type is an adapter to allow the use of ordinary function as Files mutator.

func (FilesFunc) Mutate

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

Mutate calls f(ctx, m).

type ImagesFunc

type ImagesFunc func(context.Context, *ent.ImagesMutation) (ent.Value, error)

The ImagesFunc type is an adapter to allow the use of ordinary function as Images mutator.

func (ImagesFunc) Mutate

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

Mutate calls f(ctx, m).

type MusicsFunc

type MusicsFunc func(context.Context, *ent.MusicsMutation) (ent.Value, error)

The MusicsFunc type is an adapter to allow the use of ordinary function as Musics mutator.

func (MusicsFunc) Mutate

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

Mutate calls f(ctx, m).

type OidcFunc

type OidcFunc func(context.Context, *ent.OidcMutation) (ent.Value, error)

The OidcFunc type is an adapter to allow the use of ordinary function as Oidc mutator.

func (OidcFunc) Mutate

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

Mutate calls f(ctx, m).

type PlaylistsFunc

type PlaylistsFunc func(context.Context, *ent.PlaylistsMutation) (ent.Value, error)

The PlaylistsFunc type is an adapter to allow the use of ordinary function as Playlists mutator.

func (PlaylistsFunc) Mutate

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

Mutate calls f(ctx, m).

type UsersFunc

type UsersFunc func(context.Context, *ent.UsersMutation) (ent.Value, error)

The UsersFunc type is an adapter to allow the use of ordinary function as Users mutator.

func (UsersFunc) Mutate

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

Mutate calls f(ctx, m).

type VideosFunc

type VideosFunc func(context.Context, *ent.VideosMutation) (ent.Value, error)

The VideosFunc type is an adapter to allow the use of ordinary function as Videos mutator.

func (VideosFunc) Mutate

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