Documentation
¶
Index ¶
- Variables
- func BeginTx(ctx context.Context) context.Context
- func CloseDB()
- func FromContext(ctx context.Context) *gorm.DB
- func GetDB() string
- func GetSQLConf() config.SQLConfig
- func GetSQLDB() string
- func GetSQLHost() string
- func GetSQLPass() string
- func GetSQLPort() int32
- func GetSQLSSLMode() string
- func GetSQLUser() string
- func InitializeDB(models ...interface{}) error
- func SetPagination(ctx context.Context, page, pageSize int) context.Context
- func WithContext(ctx context.Context) context.Context
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDBNotFound = errors.New("no db instance in context")
View Source
var ErrUnsupportedDB = errors.New("unsupported db type")
Functions ¶
func BeginTx ¶
BeginTx returns a context with a new transaction. If the context already has a db connection instance, it uses that instance. Otherwise, it uses the connection initialized in the package.
Ensure InitializeDB has been called before using this function.
func CloseDB ¶ added in v1.0.0
func CloseDB()
CloseDB close a connection to the database (if one exists). It panics if any error occurs.
func FromContext ¶
FromContext extracts the db connection instance from the given context.
The function panics, if a connection does not exist.
func GetSQLConf ¶
func GetSQLHost ¶
func GetSQLHost() string
func GetSQLPass ¶
func GetSQLPass() string
func GetSQLPort ¶
func GetSQLPort() int32
func GetSQLSSLMode ¶
func GetSQLSSLMode() string
func GetSQLUser ¶
func GetSQLUser() string
func InitializeDB ¶
func InitializeDB(models ...interface{}) error
InitializeDB initializes a connection to the database (if not already done) and ensures it has the latest schema.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.