Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedError

func FixedError(err error) entv1.Hook

    FixedError is a hook returning a fixed error.

    func If

    func If(hk entv1.Hook, cond Condition) entv1.Hook

      If executes the given hook under condition.

      hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
      

      func On

      func On(hk entv1.Hook, op entv1.Op) entv1.Hook

        On executes the given hook only for the given operation.

        hook.On(Log, entv1.Delete|entv1.Create)
        

        func Reject

        func Reject(op entv1.Op) entv1.Hook

          Reject returns a hook that rejects all operations that match op.

          func (T) Hooks() []entv1.Hook {
          	return []entv1.Hook{
          		Reject(entv1.Delete|entv1.Update),
          	}
          }
          

          func Unless

          func Unless(hk entv1.Hook, op entv1.Op) entv1.Hook

            Unless skips the given hook only for the given operation.

            hook.Unless(Log, entv1.Update|entv1.UpdateOne)
            

            Types

            type CarFunc

            type CarFunc func(context.Context, *entv1.CarMutation) (entv1.Value, error)

              The CarFunc type is an adapter to allow the use of ordinary function as Car mutator.

              func (CarFunc) Mutate

              func (f CarFunc) Mutate(ctx context.Context, m entv1.Mutation) (entv1.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 ...entv1.Hook) Chain

                    NewChain creates a new chain of hooks.

                    func (Chain) Append

                    func (c Chain) Append(hooks ...entv1.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() entv1.Hook

                          Hook chains the list of hooks and returns the final hook.

                          type Condition

                          type Condition func(context.Context, entv1.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 entv1.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 ConversionFunc

                                          type ConversionFunc func(context.Context, *entv1.ConversionMutation) (entv1.Value, error)

                                            The ConversionFunc type is an adapter to allow the use of ordinary function as Conversion mutator.

                                            func (ConversionFunc) Mutate

                                              Mutate calls f(ctx, m).

                                              type CustomTypeFunc

                                              type CustomTypeFunc func(context.Context, *entv1.CustomTypeMutation) (entv1.Value, error)

                                                The CustomTypeFunc type is an adapter to allow the use of ordinary function as CustomType mutator.

                                                func (CustomTypeFunc) Mutate

                                                  Mutate calls f(ctx, m).

                                                  type UserFunc

                                                  type UserFunc func(context.Context, *entv1.UserMutation) (entv1.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 entv1.Mutation) (entv1.Value, error)

                                                      Mutate calls f(ctx, m).

                                                      Source Files