Documentation
¶
Index ¶
- Constants
- func CreateFile(filename string) error
- func CreateMigrationFiles(filename string) error
- func IsConnClosed(err error) bool
- func IsConnTerminated(err error) bool
- func IsDuplicate(err error) bool
- func IsForeignNotFound(err error) bool
- func IsInvalidInput(err error) bool
- func IsNotFound(err error) bool
- func Migration(data *gorm.DB) (*migrate.Migrate, error)
- func RollbackMigration(migration *migrate.Migrate) error
- func RunMigration(migration *migrate.Migrate) error
- func TranslateQuery(db *gorm.DB, query *Query) *gorm.DB
- type Config
- type Filter
- type Ordering
- type Query
Constants ¶
const ( Equal = "Equal" LessThan = "LessThan" GreaterThan = "GreaterThan" GreaterThanEqual = "GreaterThanEqual" LessThanEqual = "LessThanEqual" IN = "IN" JSON = "JSON" Like = "Like" Descending = "Descending" Ascending = "Ascending" )
Variables ¶
This section is empty.
Functions ¶
func CreateMigrationFiles ¶
CreateMigrationFiles for postgres and put in migration folder
func IsConnClosed ¶ added in v0.4.0
IsConnClosed check error from sql if the connection was closed
func IsConnTerminated ¶ added in v0.4.0
IsConnTerminated check error from sql if the connection was terminated
func IsDuplicate ¶ added in v0.3.0
IsDuplicate check error from postgres if error is because duplicated record
func IsForeignNotFound ¶ added in v0.3.0
IsForeignNotFound check error from postgres if error is because foreign key not found
func IsInvalidInput ¶ added in v0.3.0
IsInvalidInput check error from postgres if error is because invalid input enumeration
func IsNotFound ¶ added in v0.3.0
IsNotFound check error from postgres if error is because record not found
func RollbackMigration ¶
RollbackMigration rollback the database migration
func RunMigration ¶
RunMigration run the database migration
Types ¶
type Config ¶
type Config struct {
Database string
Host string
Port int
Username string
Password string
Params string
MaxIdleConn int
MaxOpenConn int
LogMode string
DebugEnabled bool
}
Config struct to create new postgres connection client
{
Database: the postgres database name
Host: the postgres database host (localhost)
Port: the postgres database port (5432)
Username: the postgres database username
Password: the postgres database password
Params: the postgres database params, use space to separate value (sslmode=disable TimeZone=Asia/Jakarta)
MaxIdleConn: sets the maximum number of connections in the idle connection pool.
MaxOpenConn: sets the maximum number of open connections to the database.
LogMode: sets log mode, (silent) - (error) - (warn) - (info), default is Silent
DebugEnabled: sets true if enabled debug mode, will show query on console
}
type Ordering ¶ added in v0.3.0
Ordering set ordering result
func NewOrdering ¶ added in v0.3.0
NewOrdering create a new property Ordering