db

package
v0.0.0-...-8324b8c Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package db provides clients that can connect to various types of databases.

More detail: https://gorm.io/docs

Index

Constants

View Source
const (
	MySQLType      = "MySQL"
	PostgreSQLType = "PostgreSQL"

	MySQLDSN      = "%s:%s@tcp(%s:%s)/%s?parseTime=true&charset=utf8mb4"
	PostgreSQLDSN = "user=%s password=%s host=%s port=%s dbname=%s"
)

Variables

This section is empty.

Functions

func GetDBConnect

func GetDBConnect() *gorm.DB

GetDBConnect get db connection. Created by initializing configuration parameters.

After calling, *sql.DB's Close() function cannot be used to close the connection, which will cause the database connection pool to close, resulting in no database connection available.

func InitDBConnectPool

func InitDBConnectPool(dbType, host, user, passwd, dbName string, maxConn, maxIdelConn, coonMaxIdel int) (err error)

InitDBConnectPool initialize database connection based on database type.

Turn off automatic table creation in the program, table management should rely on external initialization.

Types

type Model

type Model struct {
	ID            uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	Name          string    `gorm:"type:VARCHAR(255) NOT NULL"`
	Revision      int       `gorm:"type:BIGINT UNSIGNED NOT NULL"`
	ModelUID      string    `gorm:"type:VARCHAR(63) NOT NULL;unique;uniqueIndex:uk_model_uid"`
	GroupUIDRefer string    `gorm:"type:VARCHAR(63) NOT NULL;column:group_uid"`
	IsBuiltin     bool      `gorm:"type:UNSIGNED TINYINT;column:is_builtin;default:0"`
	CreateAT      time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT      time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (Model) TableName

func (m Model) TableName() string

type ModelAssociation

type ModelAssociation struct {
	ID                        uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	AssociationUID            string    `gorm:"type:VARCHAR(63) NOT NULL;column:association_uid;uniqueIndex:uk_association_uid"`
	ModelUIDRefer             string    `gorm:"type:VARCHAR(63) NOT NULL;column:model_uid;index:idx_model_association"`
	AssociationModelUIDRefer  string    `gorm:"type:VARCHAR(63) NOT NULL;column:association_model_uid;index:idx_model_association"`
	AssociationStatusUIDRefer string    `gorm:"type:VARCHAR(63) NOT NULL;column:association_status_uid;index:idx_model_association"`
	CreateAT                  time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT                  time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelAssociation) TableName

func (ma ModelAssociation) TableName() string

type ModelAssociationStatus

type ModelAssociationStatus struct {
	ID                   uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	Name                 string    `gorm:"type:VARCHAR(255) NOT NULL"`
	AssociationStatusUID string    `gorm:"type:VARCHAR(63) NOT NULL;unique;uniqueIndex:uk_association_status_uid"`
	Description          string    `gorm:"type:VARCHAR(1023)"`
	CreateAT             time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT             time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelAssociationStatus) TableName

func (mas ModelAssociationStatus) TableName() string

type ModelDataCollection

type ModelDataCollection struct {
	ID             uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	Name           string    `gorm:"type:VARCHAR(255) NOT NULL"`
	ModelUIDRefer  string    `gorm:"type:VARCHAR(63) NOT NULL;column:model_uid"`
	CollectionUID  string    `gorm:"type:VARCHAR(63) NOT NULL;uniqueIndex:uk_model_data_collection_uid"`
	ScarpeEndpoint string    `gorm:"type:VARCHAR(63) NOT NULL"`
	CreateAT       time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT       time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelDataCollection) TableName

func (mc ModelDataCollection) TableName() string

type ModelField

type ModelField struct {
	ID            uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	Name          string    `gorm:"type:VARCHAR(255) NOT NULL"`
	FieldUID      string    `gorm:"type:VARCHAR(255) NOT NULL;unique;uniqueIndex:uk_model_field_uid"`
	ModelUIDRefer string    `gorm:"type:VARCHAR(63) NOT NULL;column:model_uid"`
	IsEditable    bool      `gorm:"type:UNSIGNED TINYINT;default:1"`
	IsOptional    bool      `gorm:"type:UNSIGNED TINYINT;default:1"`
	Description   string    `gorm:"type:VARCHAR(1023)"`
	CreateAT      time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT      time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelField) TableName

func (mf ModelField) TableName() string

type ModelGroup

type ModelGroup struct {
	ID          uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	Name        string    `gorm:"type:VARCHAR(255) NOT NULL"`
	GroupUID    string    `gorm:"type:VARCHAR(63) NOT NULL;unique;uniqueIndex:uk_model_group_uid"`
	Description string    `gorm:"type:VARCHAR(1023)"`
	CreateAT    time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT    time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelGroup) TableName

func (mg ModelGroup) TableName() string

type ModelResource

type ModelResource struct {
	ID                 uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	ModelUIDRefer      string    `gorm:"type:VARCHAR(63) NOT NULL;column:model_uid"`
	ResourceUID        string    `gorm:"type:VARCHAR(63) NOT NULL;uniqueIndex:uk_model_resource_uid"`
	CollectionUIDRefer string    `gorm:"type:VARCHAR(63);column:collection_uid"`
	IsAutoCollected    bool      `gorm:"type:UNSIGNED TINYINT;default:0"`
	CreateAT           time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT           time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelResource) TableName

func (mr ModelResource) TableName() string

type ModelResourceFieldData

type ModelResourceFieldData struct {
	ID               uint      `gorm:"type:BIGINT UNSIGNED AUTO_INCREMENT;primaryKey"`
	Data             string    `gorm:"type:VARCHAR(1023) NOT NULL"`
	ModelUIDRefer    string    `gorm:"type:VARCHAR(63) NOT NULL;column:model_uid"`
	FieldUIDRefer    string    `gorm:"type:BIGINT UNSIGNED NOT NULL;column:field_uid;index:idx_model_resource_field_data"`
	ResourceUIDRefer string    `gorm:"type:BIGINT UNSIGNED NOT NULL;column:resource_uid;index:idx_model_resource_field_data"`
	CreateAT         time.Time `gorm:"type:TIMESTAMP;column:gmt_create;autoCreateTime:true"`
	UpdateAT         time.Time `gorm:"type:TIMESTAMP;column:gmt_modified;autoUpdateTime:true"`
}

func (ModelResourceFieldData) TableName

func (md ModelResourceFieldData) TableName() string

Jump to

Keyboard shortcuts

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