plug

package
v0.0.0-...-baca244 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePlug

type BasePlug struct {
	// contains filtered or unexported fields
}

func NewBasePlug

func NewBasePlug(name ...string) *BasePlug

func (*BasePlug) WalkFields

func (p *BasePlug) WalkFields(db *gorm.DB, callback func(*gorm.DB, *schema.Field))

WalkFields walks all fields of the model, and call callback. This is a useful method for building a plug, see time.go for example.

func (*BasePlug) WalkFieldsByName

func (p *BasePlug) WalkFieldsByName(db *gorm.DB, callback func(*gorm.DB, *schema.Field))

func (*BasePlug) WalkFieldsByTag

func (p *BasePlug) WalkFieldsByTag(db *gorm.DB, callback func(*gorm.DB, *schema.Field))

func (*BasePlug) WithFields

func (p *BasePlug) WithFields(fields ...string) *BasePlug

func (*BasePlug) WithTag

func (p *BasePlug) WithTag(tag string) *BasePlug

type CryptoPlug

type CryptoPlug struct {
	BasePlug
	// contains filtered or unexported fields
}

CryptoPlug is a plug for encrypt / decrypt data. NOTE: The encryptFn and decryptFn must be set, and the target column must be []byte type.

func NewCryptoPlug

func NewCryptoPlug(name ...string) *CryptoPlug

func (*CryptoPlug) Finalize

func (p *CryptoPlug) Finalize(db *gorm.DB) error

func (*CryptoPlug) Initialize

func (p *CryptoPlug) Initialize(db *gorm.DB) error

func (*CryptoPlug) Name

func (p *CryptoPlug) Name() string

func (*CryptoPlug) WithDecryptFn

func (p *CryptoPlug) WithDecryptFn(fn func(context.Context, []byte) ([]byte, error)) *CryptoPlug

func (*CryptoPlug) WithEncryptFn

func (p *CryptoPlug) WithEncryptFn(fn func(context.Context, []byte) ([]byte, error)) *CryptoPlug

func (*CryptoPlug) WithFields

func (p *CryptoPlug) WithFields(fields ...string) *CryptoPlug

func (*CryptoPlug) WithTag

func (p *CryptoPlug) WithTag(tag string) *CryptoPlug

type Plug

type Plug interface {
	gorm.Plugin
	Finalize(*gorm.DB) error
}

type TimePlug

type TimePlug struct {
	BasePlug
	// contains filtered or unexported fields
}

func NewTimePlug

func NewTimePlug(name ...string) *TimePlug

NewTimePlug creates a new time plug, name is optional. If you want to call db.Use() twice, you must set a unique name, otherwise the second call will cause a error by gorm.

func (*TimePlug) Finalize

func (p *TimePlug) Finalize(db *gorm.DB) error

func (*TimePlug) Initialize

func (p *TimePlug) Initialize(db *gorm.DB) error

func (*TimePlug) Name

func (p *TimePlug) Name() string

func (*TimePlug) WithFields

func (p *TimePlug) WithFields(fields ...string) *TimePlug

func (*TimePlug) WithTag

func (p *TimePlug) WithTag(tag string) *TimePlug

func (*TimePlug) WithTimeFn

func (p *TimePlug) WithTimeFn(fn func() time.Time) *TimePlug

Jump to

Keyboard shortcuts

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