storage

package
v0.0.0-...-ca7777c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const NanosecondPerMillisecond = 1e6

Variables

This section is empty.

Functions

func Dsn

func Dsn(user, password, ip, port, database, charset string, timeout, readTimeout, writeTimeout time.Duration) string

func NewLog

func NewLog(log slog.Logger, opts ...func(*logger.Config)) logger.Interface

Types

type Base

type Base struct {
	ID        uint64    `json:"id,string" gorm:"primary_key:id"`
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at;not null;comment:创建时间"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;not null;comment:更新时间"`
	DeletedAt DeletedAt `json:"-" gorm:"column:deleted_at;index;comment:删除时间"`
}

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(db *gorm.DB) error

type DB

type DB struct {
	*gorm.DB
}

func New

func New(ctx context.Context, opts ...Option) (*DB, error)

New init DB

func (*DB) Close

func (d *DB) Close() error

type Deleted

type Deleted uint64

func (Deleted) DeleteClauses

func (d Deleted) DeleteClauses(f *schema.Field) []clause.Interface

func (Deleted) QueryClauses

func (d Deleted) QueryClauses(f *schema.Field) []clause.Interface

func (Deleted) UpdateClauses

func (d Deleted) UpdateClauses(field *schema.Field) []clause.Interface

type DeletedAt

type DeletedAt sql.NullTime

func (DeletedAt) DeleteClauses

func (DeletedAt) DeleteClauses(f *schema.Field) []clause.Interface

func (DeletedAt) MarshalJSON

func (n DeletedAt) MarshalJSON() ([]byte, error)

func (DeletedAt) QueryClauses

func (DeletedAt) QueryClauses(f *schema.Field) []clause.Interface

func (*DeletedAt) Scan

func (n *DeletedAt) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*DeletedAt) UnmarshalJSON

func (n *DeletedAt) UnmarshalJSON(b []byte) error

func (DeletedAt) UpdateClauses

func (d DeletedAt) UpdateClauses(field *schema.Field) []clause.Interface

func (DeletedAt) Value

func (n DeletedAt) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type IgnoreSelectLogger

type IgnoreSelectLogger struct {
}

func (IgnoreSelectLogger) Initialize

func (IgnoreSelectLogger) Initialize(db *gorm.DB) error

func (IgnoreSelectLogger) Name

func (IgnoreSelectLogger) Name() string

type Option

type Option func(*option)

func WithCharset

func WithCharset(charset string) Option

func WithDatabase

func WithDatabase(db string) Option

func WithIP

func WithIP(ip string) Option

func WithLogger

func WithLogger(logger glogger.Interface) Option

func WithMaxIdleConn

func WithMaxIdleConn(maxIdleConn int) Option

func WithMaxLifetime

func WithMaxLifetime(connMaxLifetime time.Duration) Option

func WithMaxOpenConn

func WithMaxOpenConn(maxOpenConn int) Option

func WithPassword

func WithPassword(password string) Option

func WithPlugins

func WithPlugins(plugins ...gorm.Plugin) Option

func WithPort

func WithPort(port string) Option

func WithReadTimeout

func WithReadTimeout(readTimeout time.Duration) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithUser

func WithUser(user string) Option

func WithWriteTimeout

func WithWriteTimeout(writeTimeout time.Duration) Option

type SoftDeleteDeleteClause

type SoftDeleteDeleteClause struct {
	Field *schema.Field
}

func (SoftDeleteDeleteClause) Build

func (SoftDeleteDeleteClause) MergeClause

func (sd SoftDeleteDeleteClause) MergeClause(*clause.Clause)

func (SoftDeleteDeleteClause) ModifyStatement

func (sd SoftDeleteDeleteClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeleteDeleteClause) Name

func (sd SoftDeleteDeleteClause) Name() string

type SoftDeleteDeletedClause

type SoftDeleteDeletedClause struct {
	Field *schema.Field
}

func (SoftDeleteDeletedClause) Build

func (SoftDeleteDeletedClause) MergeClause

func (s SoftDeleteDeletedClause) MergeClause(*clause.Clause)

func (SoftDeleteDeletedClause) ModifyStatement

func (s SoftDeleteDeletedClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeleteDeletedClause) Name

type SoftDeleteQueryClause

type SoftDeleteQueryClause struct {
	Field *schema.Field
}

func (SoftDeleteQueryClause) Build

func (SoftDeleteQueryClause) MergeClause

func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause)

func (SoftDeleteQueryClause) ModifyStatement

func (sd SoftDeleteQueryClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeleteQueryClause) Name

func (sd SoftDeleteQueryClause) Name() string

type SoftDeletedAtUpdateClause

type SoftDeletedAtUpdateClause struct {
	Field *schema.Field
}

func (SoftDeletedAtUpdateClause) Build

func (SoftDeletedAtUpdateClause) MergeClause

func (s SoftDeletedAtUpdateClause) MergeClause(*clause.Clause)

func (SoftDeletedAtUpdateClause) ModifyStatement

func (s SoftDeletedAtUpdateClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeletedAtUpdateClause) Name

type SoftDeletedQueryClause

type SoftDeletedQueryClause struct {
	Field *schema.Field
}

func (SoftDeletedQueryClause) Build

func (SoftDeletedQueryClause) MergeClause

func (s SoftDeletedQueryClause) MergeClause(*clause.Clause)

func (SoftDeletedQueryClause) ModifyStatement

func (s SoftDeletedQueryClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeletedQueryClause) Name

func (s SoftDeletedQueryClause) Name() string

type SoftDeletedUpdateClause

type SoftDeletedUpdateClause struct {
	Field *schema.Field
}

func (SoftDeletedUpdateClause) Build

func (SoftDeletedUpdateClause) MergeClause

func (s SoftDeletedUpdateClause) MergeClause(*clause.Clause)

func (SoftDeletedUpdateClause) ModifyStatement

func (s SoftDeletedUpdateClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeletedUpdateClause) Name

Jump to

Keyboard shortcuts

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