Documentation ¶
Index ¶
- func IsDuplicateError(err error, dbtype string) bool
- func IsStringInSlice(needle string, haystack []string) bool
- func TranslateErrors(err error, dbtype string) error
- type Column
- type Conn
- func (c *Conn) AutoMigrate(dst ...interface{}) error
- func (c *Conn) GetDB() *gorm.DB
- func (c *Conn) GetQuery() *query.Query
- func (c *Conn) MustExec(sql string, values ...interface{})
- func (c *Conn) Raw(sql string, values ...interface{}) *gorm.DB
- func (c *Conn) ScanRows(rows *sql.Rows, dest interface{}) error
- func (c *Conn) SourceSQL(filename string)
- type DBType
- type Database
- type GeneralDatabase
- type NetworkDB
- type SSL
- type Storage
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDuplicateError ¶
func IsStringInSlice ¶
isStringInSlice checks if needle (string) is in haystack ([]string).
func TranslateErrors ¶
Types ¶
type Column ¶
type Column struct { OrdinalPosition int `json:"ordinal_position" gorm:"column:ordinal_position"` Name string `json:"column_name" gorm:"column:column_name"` DataType string `json:"data_type" gorm:"column:data_type"` DefaultValue sql.NullString `json:"column_default" gorm:"column:column_default"` IsNullable string `json:"is_nullable" gorm:"column:is_nullable"` CharacterMaximumLength sql.NullInt64 `json:"character_maximum_length" gorm:"column:character_maximum_length"` NumericPrecision sql.NullInt64 `json:"numeric_precision" gorm:"column:numeric_precision"` ColumnKey string `json:"column_key" gorm:"column:column_key"` // mysql specific Extra string `json:"extra" gorm:"column:extra"` // mysql specific ConstraintName sql.NullString `json:"constraint_name" gorm:"column:constraint_name"` // pg specific ConstraintType sql.NullString `json:"constraint_type" gorm:"column:constraint_type"` // pg specific }
Column stores information about a column.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) AutoMigrate ¶
type Database ¶
type Database interface { GetTables() (tables []*Table, err error) // PrepareGetColumnsOfTableStmt() (err error) GetColumnsOfTable(table *Table) (err error) IsPrimaryKey(column Column) bool IsAutoIncrement(column Column) bool IsNullable(column Column) bool GetStringDatatypes() []string IsString(column Column) bool GetTextDatatypes() []string IsText(column Column) bool GetIntegerDatatypes() []string IsInteger(column Column) bool GetFloatDatatypes() []string IsFloat(column Column) bool GetTemporalDatatypes() []string IsTemporal(column Column) bool }
Database interface for the concrete databases.
type GeneralDatabase ¶
type GeneralDatabase struct {
// contains filtered or unexported fields
}
GeneralDatabase represents a base "class" database - for all other concrete databases it implements partly the Database interface.
func (*GeneralDatabase) Close ¶
func (gdb *GeneralDatabase) Close() error
Close closes the database connection.
func (*GeneralDatabase) Connect ¶
func (gdb *GeneralDatabase) Connect(dsn string) (err error)
Connect establishes a connection to the database with the given DSN. It pings the database to ensure it is reachable.
func (*GeneralDatabase) IsNullable ¶
func (gdb *GeneralDatabase) IsNullable(column Column) bool
IsNullable returns true if the column is a nullable column.
type NetworkDB ¶
type NetworkDB struct { Database string User string Password string Host string Port uint16 Debug bool ConnectionTimeout int // Seconds // database/sql tunables, see // https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime and below // Note: defaults will be set if these are 0 MaxOpenConns int `json:"maxOpenConns"` // default: 5 MaxIdleConns int `json:"maxIdleConns"` // default: 5 ConnMaxLifetime int `json:"connMaxLifetime"` // Seconds, default: not set }
NetworkDB contains options common to SQL databases accessed over network.
Click to show internal directories.
Click to hide internal directories.