Documentation ¶
Index ¶
- func DatabaseMigrationURL() (string, error)
- func DatabaseTestURL() (string, error)
- func DatabaseURL() (string, error)
- type MySqlAdapter
- type MySqlAdapterConfig
- type PostgreSqlAdapter
- func (m PostgreSqlAdapter) Config() *SqlAdapterConfig
- func (m PostgreSqlAdapter) GetConn() (*sql.DB, error)
- func (m PostgreSqlAdapter) GetDB() (*gorm.DB, error)
- func (m PostgreSqlAdapter) Migrate(tables ...interface{}) error
- func (m PostgreSqlAdapter) Ping() error
- func (m PostgreSqlAdapter) SetupConnectionPool() error
- type PostgreSqlAdapterConfig
- type SqlAdapterConfig
- type SqlDataAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseMigrationURL ¶
DatabaseMigrationURL returns the DSN to connect to the database for schema migration using a conventional environment variable. If the schema migration DSN is not set, it will fallback to the regular database DSN.
func DatabaseTestURL ¶
DatabaseTestURL returns the DSN to connect to the test database using a conventional environment variable.
func DatabaseURL ¶
DatabaseURL returns the DSN to connect to the database using a conventional environment variable.
Types ¶
type MySqlAdapter ¶
type MySqlAdapter struct {
// contains filtered or unexported fields
}
func (MySqlAdapter) Config ¶
func (m MySqlAdapter) Config() *SqlAdapterConfig
func (MySqlAdapter) SetupConnectionPool ¶
func (m MySqlAdapter) SetupConnectionPool() error
type MySqlAdapterConfig ¶
type PostgreSqlAdapter ¶
type PostgreSqlAdapter struct {
// contains filtered or unexported fields
}
func (PostgreSqlAdapter) Config ¶
func (m PostgreSqlAdapter) Config() *SqlAdapterConfig
func (PostgreSqlAdapter) SetupConnectionPool ¶
func (m PostgreSqlAdapter) SetupConnectionPool() error
type PostgreSqlAdapterConfig ¶
type PostgreSqlAdapterConfig struct { DSN string // A name to report as part of the tracer plugin TracingDBName string // Translate errors to gorms internal error types TranslateError bool EnableTracing bool EnableMetrics bool // This is an optional pointer to the SqlAdapterConfig struct. // If not supplied, we will use the defaultSqlAdapterConfig. SqlAdapterConfig *SqlAdapterConfig }
GORM internally uses pgx as the default driver for PostgreSQL. The DSN format can be anything supported by pgx. For example: postgres://${user}:${password}@${host}/${db}?sslmode=verify-none
type SqlAdapterConfig ¶
func DefaultSqlAdapterConfig ¶
func DefaultSqlAdapterConfig() SqlAdapterConfig
type SqlDataAdapter ¶
type SqlDataAdapter interface { GetDB() (*gorm.DB, error) GetConn() (*sql.DB, error) Migrate(...interface{}) error Ping() error }
SqlDataAdapter represents a contract for implementing RDBMS data adapters
func NewMySqlAdapter ¶
func NewMySqlAdapter(config MySqlAdapterConfig) (SqlDataAdapter, error)
func NewPostgreSqlAdapter ¶
func NewPostgreSqlAdapter(config PostgreSqlAdapterConfig) (SqlDataAdapter, error)