db

package
v0.0.0-...-074af59 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRDBInstance map[string]*gorm.DB
View Source
var DBInstance map[string]*gorm.DB
View Source
var FindColumnsSql = `
	SELECT COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_DEFAULT
	FROM information_schema.COLUMNS 
	WHERE TABLE_NAME = ?
`

Functions

func AddJSONFormGormTag

func AddJSONFormGormTag(in string) string

AddJSONFormGormTag adds json format

func AddressCrdb

func AddressCrdb() string

func ConnectCrdb

func ConnectCrdb() map[string]*gorm.DB

func ConnectSql

func ConnectSql() map[string]*gorm.DB

func FindUpperElement

func FindUpperElement(s string) []string

FindUpperElement finds a list of uppercase letters in the string, attached to HumpToUnderLine

func GenerateFile

func GenerateFile(filePath string, content string) error

create file model

func GenerateModel

func GenerateModel(source string, tableName string) interface{}

func HumpToUnderLine

func HumpToUnderLine(s string) string

HumpToUnderLine hump underline

func InfoSql

func InfoSql() string

func Split

func Split(s string, sub string) []string

Split Enhanced Split, for a,,,,,,,b,,c cut to "a,b,c] with ","

func Split2

func Split2(s string, sub string, tmp *string, rs *[]string)

Split2 is attached to Split and can be used independently

func TableToStruct

func TableToStruct(dataSource string, tableName string) string

generate go model y specific the dataSource and table name

func UnderLineToHump

func UnderLineToHump(s string) string

UnderLineToHump underline to hump

Types

type Column

type Column struct {
	ColumnNumber  int    `gorm:"column_number "` // column index
	ColumnName    string `gorm:"column_name"`    // column_name
	DataType      string `gorm:"data_type"`      // column_type
	ColumnDefault string `gorm:"column_default"` // column_default
	IsNullAble    bool   `gorm:"is_nullable"`    // column_default
	Constraint    Index  `gorm:"indices"`        // column_default
}

func FindColumns

func FindColumns(dataSource string, tableName string) []Column

find columns' property by specific dataSource and table name

type Index

type Index struct {
	TableName string `gorm:"column:table_name"` //table name
	IndexName string `gorm:"index_name"`
	Direction string `gorm:"direction"`
}

type Table

type Table struct {
	TableName string `gorm:"column:table_name"` //table name
}

func FindTables

func FindTables(dataSource string) []Table

dataSource = fmt.Sprintf("host=%s port=%s user=%s dbname=%s sslmode=%s password=%s","localhost", "5432", "postgres", "test", "disable", "123")

Jump to

Keyboard shortcuts

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