mixin

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package mixin contains the mixin package

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTokenSize is returned when session token size is invalid
	ErrInvalidTokenSize = errors.New("invalid token size")
)

Functions

func AuditHook

func AuditHook(next ent.Mutator) ent.Mutator

AuditHook sets and returns the created_at, updated_at, etc., fields

func CheckIsSoftDelete

func CheckIsSoftDelete(ctx context.Context) bool

CheckIsSoftDelete checks if the softDeleteKey is set in the context

func CheckSkipSoftDelete

func CheckSkipSoftDelete(ctx context.Context) bool

CheckSkipSoftDelete checks if the softDeleteSkipKey is set in the context

func IsSoftDelete

func IsSoftDelete(parent context.Context) context.Context

IsSoftDelete returns a new context that informs the delete is a soft-delete for interceptor/hooks.

func SkipSoftDelete

func SkipSoftDelete(parent context.Context) context.Context

SkipSoftDelete returns a new context that skips the soft-delete interceptor/hooks.

Types

type AuditMixin

type AuditMixin struct {
	mixin.Schema
}

AuditMixin provides auditing for all records where enabled. The created_at, created_by, updated_at, and updated_by records are automatically populated when this mixin is enabled.

func (AuditMixin) Fields

func (AuditMixin) Fields() []ent.Field

Fields of the AuditMixin

func (AuditMixin) Hooks

func (AuditMixin) Hooks() []ent.Hook

Hooks of the AuditMixin

type IDMixin

type IDMixin struct {
	mixin.Schema
}

IDMixin holds the schema definition for the ID

func (IDMixin) Fields

func (IDMixin) Fields() []ent.Field

Fields of the IDMixin.

type SoftDeleteMixin

type SoftDeleteMixin struct {
	mixin.Schema
}

SoftDeleteMixin implements the soft delete pattern for schemas.

func (SoftDeleteMixin) Fields

func (SoftDeleteMixin) Fields() []ent.Field

Fields of the SoftDeleteMixin.

func (SoftDeleteMixin) Hooks

func (d SoftDeleteMixin) Hooks() []ent.Hook

Hooks of the SoftDeleteMixin.

func (SoftDeleteMixin) Interceptors

func (d SoftDeleteMixin) Interceptors() []ent.Interceptor

Interceptors of the SoftDeleteMixin.

func (SoftDeleteMixin) P

func (d SoftDeleteMixin) P(w interface{ WhereP(...func(*sql.Selector)) })

P adds a storage-level predicate to the queries and mutations.

func (SoftDeleteMixin) SoftDeleteHook

func (d SoftDeleteMixin) SoftDeleteHook(next ent.Mutator) ent.Mutator

SoftDeleteHook will soft delete records, by changing the delete mutation to an update and setting the deleted_at and deleted_by fields, unless the softDeleteSkipKey is set

type UnexpectedAuditError

type UnexpectedAuditError struct {
	MutationType ent.Mutation
}

UnexpectedAuditError is returned when an unexpected audit log call is received

func (*UnexpectedAuditError) Error

func (e *UnexpectedAuditError) Error() string

Error returns the UnexpectedAuditError in string format

type UnexpectedMutationTypeError

type UnexpectedMutationTypeError struct {
	MutationType ent.Mutation
}

UnexpectedMutationTypeError is returned when an unexpected mutation type is parsed

func (*UnexpectedMutationTypeError) Error

Error returns the UnexpectedAuditError in string format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL