gorm

package module
v0.0.0-...-359184a Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 15 Imported by: 0

README

GORM

go get -u github.com/rumorshub/gorm

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

View Source
const PluginName = "gorm"

Variables

View Source
var ErrConfigNotFound = errors.New("gorm config not found")

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Config    Config
	Dialector Dialector
	Log       *slog.Logger
	// contains filtered or unexported fields
}

func (*Channel) GetDB

func (c *Channel) GetDB(conn gorm.ConnPool) (*gorm.DB, error)

type ChannelConfig

type ChannelConfig map[string]Config

type Config

type Config struct {
	SkipDefaultTransaction                   bool `mapstructure:"skip_default_transaction" json:"skip_default_transaction,omitempty"`
	PrepareStmt                              bool `mapstructure:"prepare_stmt" json:"prepare_stmt,omitempty"`
	DisableNestedTransaction                 bool `mapstructure:"disable_nested_transaction" json:"disable_nested_transaction,omitempty"`
	AllowGlobalUpdate                        bool `mapstructure:"allow_global_update" json:"allow_global_update,omitempty"`
	DisableAutomaticPing                     bool `mapstructure:"disable_automatic_ping" json:"disable_automatic_ping,omitempty"`
	DisableForeignKeyConstraintWhenMigrating bool `mapstructure:"disable_foreign_key_constraint_when_migrating" json:"disable_foreign_key_constraint_when_migrating,omitempty"`
	IgnoreRelationshipsWhenMigrating         bool `mapstructure:"ignore_relationships_when_migrating" json:"ignore_relationships_when_migrating,omitempty"`
	TranslateError                           bool `mapstructure:"translate_error" json:"translate_error,omitempty"`
}

type ConfigMySQL

type ConfigMySQL struct {
	DriverName                    string `mapstructure:"driver_name" json:"driver_name,omitempty"`
	ServerVersion                 string `mapstructure:"server_version" json:"server_version,omitempty"`
	DSN                           string `mapstructure:"dsn" json:"dsn,omitempty"`
	SkipInitializeWithVersion     bool   `mapstructure:"skip_initialize_with_version" json:"skip_initialize_with_version,omitempty"`
	DefaultStringSize             uint   `mapstructure:"default_string_size" json:"default_string_size,omitempty"`
	DefaultDatetimePrecision      *int   `mapstructure:"default_datetime_precision" json:"default_datetime_precision,omitempty"`
	DisableWithReturning          bool   `mapstructure:"disable_with_returning" json:"disable_with_returning,omitempty"`
	DisableDatetimePrecision      bool   `mapstructure:"disable_datetime_precision" json:"disable_datetime_precision,omitempty"`
	DontSupportRenameIndex        bool   `mapstructure:"dont_support_rename_index" json:"dont_support_rename_index,omitempty"`
	DontSupportRenameColumn       bool   `mapstructure:"dont_support_rename_column" json:"dont_support_rename_column,omitempty"`
	DontSupportRenameColumnUnique bool   `mapstructure:"dont_support_rename_column_unique" json:"dont_support_rename_column_unique,omitempty"`
	DontSupportForShareClause     bool   `mapstructure:"dont_support_for_share_clause" json:"dont_support_for_share_clause,omitempty"`
	DontSupportNullAsDefaultValue bool   `mapstructure:"dont_support_null_as_default_value" json:"dont_support_null_as_default_value,omitempty"`
}

func (ConfigMySQL) Dialector

func (c ConfigMySQL) Dialector(conn gorm.ConnPool) gorm.Dialector

type ConfigPostgreSQL

type ConfigPostgreSQL struct {
	DriverName           string `mapstructure:"driver_name" json:"driver_name,omitempty"`
	DSN                  string `mapstructure:"dsn" json:"dsn,omitempty"`
	PreferSimpleProtocol bool   `mapstructure:"prefer_simple_protocol" json:"prefer_simple_protocol,omitempty"`
	WithoutReturning     bool   `mapstructure:"without_returning" json:"without_returning,omitempty"`
}

func (ConfigPostgreSQL) Dialector

func (c ConfigPostgreSQL) Dialector(conn gorm.ConnPool) gorm.Dialector

type ConfigSQLServer

type ConfigSQLServer struct {
	DriverName        string `mapstructure:"driver_name" json:"driver_name,omitempty"`
	DSN               string `mapstructure:"dsn" json:"dsn,omitempty"`
	DefaultStringSize int    `mapstructure:"default_string_size" json:"default_string_size,omitempty"`
}

func (ConfigSQLServer) Dialector

func (c ConfigSQLServer) Dialector(conn gorm.ConnPool) gorm.Dialector

type ConfigSQLite

type ConfigSQLite struct {
	DriverName string `mapstructure:"driver_name" json:"driver_name,omitempty"`
	DSN        string `mapstructure:"dsn" json:"dsn,omitempty"`
}

func (ConfigSQLite) Dialector

func (c ConfigSQLite) Dialector(conn gorm.ConnPool) gorm.Dialector

type Configurer

type Configurer interface {
	Has(name string) bool
	UnmarshalKey(name string, out interface{}) error
}

type DBGetter

type DBGetter interface {
	GetDB(name string) (*gorm.DB, error)
}

type Dialector

type Dialector interface {
	Dialector(conn gorm.ConnPool) gorm.Dialector
}

type Driver

type Driver string
const (
	MySQL      Driver = "mysql"
	PostgreSQL Driver = "postgresql"
	SQLServer  Driver = "sqlserver"
	SQLite     Driver = "sqlite"
)

type Getter

type Getter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Getter) GetDB

func (g *Getter) GetDB(name string) (*gorm.DB, error)

type Logger

type Logger interface {
	NamedLogger(name string) *slog.Logger
}

type Plugin

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

func (*Plugin) Getter

func (p *Plugin) Getter() *Getter

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer, logger Logger) error

func (*Plugin) Provides

func (p *Plugin) Provides() []*dep.Out

Jump to

Keyboard shortcuts

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