database

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverMSSQL    = "mssql"
	DriverMySQL    = "mysql"
	DriverSQLLite  = "sqlite3"
	DriverPostgres = "postgres"

	DefaultMySQLCharset = "utf8mb4"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host       string
	Port       string
	Username   string
	Password   string
	Name       string
	DebugMode  bool
	Filename   string
	SSLEnabled bool
	Charset    string
}

type Database

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

func NewWithConfig

func NewWithConfig(cfg Config, driver string) Database

func (*Database) Close

func (db *Database) Close() error

func (*Database) Connect

func (db *Database) Connect() error

func (*Database) ConnectWithGormConfig

func (db *Database) ConnectWithGormConfig(gormCfg gorm.Config) error

func (*Database) Ctx

func (db *Database) Ctx() *gorm.DB

func (*Database) MigrateDatabase

func (db *Database) MigrateDatabase(tables []interface{}) error

func (*Database) Reconnect

func (db *Database) Reconnect() error

func (*Database) SqlDB

func (db *Database) SqlDB() *sql.DB

type Model

type Model struct {
	Seq       int64          `json:"seq" gorm:"primary_key;auto_increment:false;"`
	Uid       uuid.UUID      `json:"uid" gorm:"primary_key;index"`
	CreatedAt time.Time      `json:"created_at" gorm:"index"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

Model struct

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook table

type Preload

type Preload struct {
	Column     string        `json:"column"`
	Conditions []interface{} `json:"conditions"`
}

Preload

type Where

type Where struct {
	Condition string        `json:"condition"`
	Arguments []interface{} `json:"args"`
}

Where

Jump to

Keyboard shortcuts

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