Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // PostgresOpt is default connection option for postgres. PostgresOpt = ConnectOption{ Dialect: "postgres", Host: "localhost", DBName: "postgres", Port: 5432, User: "postgres", Password: "postgres", } // SQLiteOpt is shared in-memory database. SQLiteOpt = ConnectOption{ Dialect: "sqlite3", Host: "file::memory:?cache=shared", } )
Functions ¶
func TestingInitialize ¶
func TestingInitialize(opt ConnectOption) (funcFinalize func())
TestingInitialize creates new db for testing.
Types ¶
type ConnectOption ¶
type ConnectOption struct { Dialect string Host string Port int // optional, if you append port in host, this option is unnecessary. DBName string User string Password string Config gorm.Config Silence bool Testing bool Logger logger.Interface }
ConnectOption defines a generic connect option for all dialects.
func (*ConnectOption) CliFlags ¶
func (opt *ConnectOption) CliFlags() []cli.Flag
CliFlags returns cli flag list.
func (*ConnectOption) ConnStr ¶
func (opt *ConnectOption) ConnStr() string
ConnStr generates connection string.
func (*ConnectOption) Dialector ¶
func (opt *ConnectOption) Dialector() gorm.Dialector
Dialector generates gorm Dialector.
Click to show internal directories.
Click to hide internal directories.