database

package
v1.0.1006 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryUUID

type BinaryUUID uuid.UUID

binary uuid wrapper over uuid.UUID example - gorm:"type:binary(16);default:(UUID_TO_BIN(UUID()));

func (BinaryUUID) GormDataType

func (this BinaryUUID) GormDataType() string

sql data type for gorm

func (BinaryUUID) MarshalJSON

func (this BinaryUUID) MarshalJSON() ([]byte, error)

convert to json string

func (*BinaryUUID) Scan

func (this *BinaryUUID) Scan(value any) error

scan value into BinaryUUID

func (BinaryUUID) String

func (this BinaryUUID) String() string

func (*BinaryUUID) UnmarshalJSON

func (this *BinaryUUID) UnmarshalJSON(by []byte) error

convert from json string

func (BinaryUUID) Value

func (this BinaryUUID) Value() (driver.Value, error)

return BinaryUUID to []bytes binary(16)

type ConfigMap

type ConfigMap = map[string]any

配置 map

type Database

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

*

  • 数据库 *
  • @create 2021-9-15
  • @author deatil

func New

func New(driver interfaces.Driver, conf ...ConfigMap) *Database

*

  • 使用

func (*Database) Close

func (this *Database) Close()

*

  • 关闭连接

func (*Database) GetConfig

func (this *Database) GetConfig(name string) any

获取配置

func (*Database) GetConnection

func (this *Database) GetConnection() *gorm.DB

*

  • 获取数据库连接对象db

func (*Database) GetConnectionWithDebug

func (this *Database) GetConnectionWithDebug() *gorm.DB

*

  • 获取数据库连接对象db,带debug

func (*Database) GetDriver

func (this *Database) GetDriver() interfaces.Driver

*

  • 获取驱动

func (*Database) WithConfig

func (this *Database) WithConfig(config ConfigMap) interfaces.Database

设置配置

func (*Database) WithDriver

func (this *Database) WithDriver(driver interfaces.Driver) interfaces.Database

*

  • 设置驱动

type Datetime

type Datetime sql.NullTime

custom time types Used to format time into a human-readable string

func (Datetime) MarshalJSON

func (this Datetime) MarshalJSON() ([]byte, error)

func (*Datetime) Scan

func (this *Datetime) Scan(value any) error

Scan implements the Scanner interface.

func (*Datetime) UnmarshalJSON

func (this *Datetime) UnmarshalJSON(b []byte) error

func (Datetime) Value

func (this Datetime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Model

type Model struct {
	Id        uint     `gorm:"column:record_id;primaryKey;autoIncrement;" json:"-"`
	CreatedAt Datetime `gorm:"column:created_at;autoCreateTime;" json:"created_at"`
	UpdatedAt Datetime `gorm:"column:updated_at;autoUpdateTime;" json:"updated_at"`
}

Model base model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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