database

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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