hook

package
v0.0.0-...-05e3429 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 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 AddressFunc

type AddressFunc func(context.Context, *ent.AddressMutation) (ent.Value, error)

The AddressFunc type is an adapter to allow the use of ordinary function as Address mutator.

func (AddressFunc) Mutate

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

type ConversationFunc func(context.Context, *ent.ConversationMutation) (ent.Value, error)

The ConversationFunc type is an adapter to allow the use of ordinary function as Conversation mutator.

func (ConversationFunc) Mutate

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

Mutate calls f(ctx, m).

type InvoiceFunc

type InvoiceFunc func(context.Context, *ent.InvoiceMutation) (ent.Value, error)

The InvoiceFunc type is an adapter to allow the use of ordinary function as Invoice mutator.

func (InvoiceFunc) Mutate

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

Mutate calls f(ctx, m).

type InvoiceHistoryFunc

type InvoiceHistoryFunc func(context.Context, *ent.InvoiceHistoryMutation) (ent.Value, error)

The InvoiceHistoryFunc type is an adapter to allow the use of ordinary function as InvoiceHistory mutator.

func (InvoiceHistoryFunc) Mutate

Mutate calls f(ctx, m).

type InvoiceStatusCodeFunc

type InvoiceStatusCodeFunc func(context.Context, *ent.InvoiceStatusCodeMutation) (ent.Value, error)

The InvoiceStatusCodeFunc type is an adapter to allow the use of ordinary function as InvoiceStatusCode mutator.

func (InvoiceStatusCodeFunc) Mutate

Mutate calls f(ctx, m).

type MessageFunc

type MessageFunc func(context.Context, *ent.MessageMutation) (ent.Value, error)

The MessageFunc type is an adapter to allow the use of ordinary function as Message mutator.

func (MessageFunc) Mutate

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

Mutate calls f(ctx, m).

type OrderFunc

type OrderFunc func(context.Context, *ent.OrderMutation) (ent.Value, error)

The OrderFunc type is an adapter to allow the use of ordinary function as Order mutator.

func (OrderFunc) Mutate

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

Mutate calls f(ctx, m).

type OrderHistoryFunc

type OrderHistoryFunc func(context.Context, *ent.OrderHistoryMutation) (ent.Value, error)

The OrderHistoryFunc type is an adapter to allow the use of ordinary function as OrderHistory mutator.

func (OrderHistoryFunc) Mutate

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

Mutate calls f(ctx, m).

type OrderItemFunc

type OrderItemFunc func(context.Context, *ent.OrderItemMutation) (ent.Value, error)

The OrderItemFunc type is an adapter to allow the use of ordinary function as OrderItem mutator.

func (OrderItemFunc) Mutate

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

Mutate calls f(ctx, m).

type OrderStatusCodeFunc

type OrderStatusCodeFunc func(context.Context, *ent.OrderStatusCodeMutation) (ent.Value, error)

The OrderStatusCodeFunc type is an adapter to allow the use of ordinary function as OrderStatusCode mutator.

func (OrderStatusCodeFunc) Mutate

Mutate calls f(ctx, m).

type PersonAddressFunc

type PersonAddressFunc func(context.Context, *ent.PersonAddressMutation) (ent.Value, error)

The PersonAddressFunc type is an adapter to allow the use of ordinary function as PersonAddress mutator.

func (PersonAddressFunc) Mutate

Mutate calls f(ctx, m).

type PersonFunc

type PersonFunc func(context.Context, *ent.PersonMutation) (ent.Value, error)

The PersonFunc type is an adapter to allow the use of ordinary function as Person mutator.

func (PersonFunc) Mutate

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

Mutate calls f(ctx, m).

type ProductColorFunc

type ProductColorFunc func(context.Context, *ent.ProductColorMutation) (ent.Value, error)

The ProductColorFunc type is an adapter to allow the use of ordinary function as ProductColor mutator.

func (ProductColorFunc) Mutate

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

Mutate calls f(ctx, m).

type ProductImageFunc

type ProductImageFunc func(context.Context, *ent.ProductImageMutation) (ent.Value, error)

The ProductImageFunc type is an adapter to allow the use of ordinary function as ProductImage mutator.

func (ProductImageFunc) Mutate

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

Mutate calls f(ctx, m).

type ProductInfoFunc

type ProductInfoFunc func(context.Context, *ent.ProductInfoMutation) (ent.Value, error)

The ProductInfoFunc type is an adapter to allow the use of ordinary function as ProductInfo mutator.

func (ProductInfoFunc) Mutate

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

Mutate calls f(ctx, m).

type ProductQtyFunc

type ProductQtyFunc func(context.Context, *ent.ProductQtyMutation) (ent.Value, error)

The ProductQtyFunc type is an adapter to allow the use of ordinary function as ProductQty mutator.

func (ProductQtyFunc) Mutate

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

Mutate calls f(ctx, m).

type ProductTagFunc

type ProductTagFunc func(context.Context, *ent.ProductTagMutation) (ent.Value, error)

The ProductTagFunc type is an adapter to allow the use of ordinary function as ProductTag mutator.

func (ProductTagFunc) Mutate

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

Mutate calls f(ctx, m).

type ShipmentFunc

type ShipmentFunc func(context.Context, *ent.ShipmentMutation) (ent.Value, error)

The ShipmentFunc type is an adapter to allow the use of ordinary function as Shipment mutator.

func (ShipmentFunc) Mutate

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

Mutate calls f(ctx, m).

type ShipmentHistoryFunc

type ShipmentHistoryFunc func(context.Context, *ent.ShipmentHistoryMutation) (ent.Value, error)

The ShipmentHistoryFunc type is an adapter to allow the use of ordinary function as ShipmentHistory mutator.

func (ShipmentHistoryFunc) Mutate

Mutate calls f(ctx, m).

type ShipmentItemFunc

type ShipmentItemFunc func(context.Context, *ent.ShipmentItemMutation) (ent.Value, error)

The ShipmentItemFunc type is an adapter to allow the use of ordinary function as ShipmentItem mutator.

func (ShipmentItemFunc) Mutate

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

Mutate calls f(ctx, m).

type ShipmentStatusCodeFunc

type ShipmentStatusCodeFunc func(context.Context, *ent.ShipmentStatusCodeMutation) (ent.Value, error)

The ShipmentStatusCodeFunc type is an adapter to allow the use of ordinary function as ShipmentStatusCode mutator.

func (ShipmentStatusCodeFunc) Mutate

Mutate calls f(ctx, m).

type TagFunc

type TagFunc func(context.Context, *ent.TagMutation) (ent.Value, error)

The TagFunc type is an adapter to allow the use of ordinary function as Tag mutator.

func (TagFunc) Mutate

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

Mutate calls f(ctx, m).

type WarehouseAssignmentFunc

type WarehouseAssignmentFunc func(context.Context, *ent.WarehouseAssignmentMutation) (ent.Value, error)

The WarehouseAssignmentFunc type is an adapter to allow the use of ordinary function as WarehouseAssignment mutator.

func (WarehouseAssignmentFunc) Mutate

Mutate calls f(ctx, m).

type WorkUnitInfoFunc

type WorkUnitInfoFunc func(context.Context, *ent.WorkUnitInfoMutation) (ent.Value, error)

The WorkUnitInfoFunc type is an adapter to allow the use of ordinary function as WorkUnitInfo mutator.

func (WorkUnitInfoFunc) Mutate

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