Documentation ¶
Overview ¶
Package postgresdb ...
Index ¶
- Constants
- func DataSourceName(username string, password string, address string, dbName string, ...) string
- func NewDB(conf *Config, logger logging.Logger) (*gorm.DB, error)
- func NewDBFromENV(logger logging.Logger) (*gorm.DB, error)
- type Config
- type DBClient
- func (db *DBClient) Clear()
- func (db *DBClient) Create(value interface{}) (err error)
- func (db *DBClient) Delete(value interface{}, where interface{}) (err error)
- func (db *DBClient) Find(value interface{}, where interface{}, args ...interface{}) (err error)
- func (db *DBClient) FindFirst(value interface{}, where interface{}, args ...interface{}) (err error)
- func (db *DBClient) FindWithOrder(value interface{}, order string, where interface{}) (err error)
- func (db *DBClient) Save(value interface{}) (err error)
- func (db *DBClient) Session() *gorm.DB
- func (db *DBClient) Update(value interface{}, where interface{}) (err error)
Constants ¶
View Source
const ( ObjectNotExist gerrors.ErrorCode = "Object Not Exists" DuplicateRecord gerrors.ErrorCode = "Record already Exist" AuthenticationFailed gerrors.ErrorCode = "Authentication Failed" PostgresDBError gerrors.ErrorCode = "Postgres DB Error" NoError gerrors.ErrorCode = "No Error" )
View Source
const ( DBConnectError gerrors.ErrorCode = "Error connecting to the DB" GormGetDialectError gerrors.ErrorCode = "Error connecting to the DB" )
Variables ¶
This section is empty.
Functions ¶
func DataSourceName ¶
Types ¶
type Config ¶
type Config struct { Username string `envconfig:"PG_DB_SERVICE_USERNAME" required:"true"` Password string `envconfig:"PG_DB_SERVICE_USERPASSWORD" required:"false"` DBHost string `envconfig:"PG_DB_HOST" required:"true"` DBPort string `envconfig:"PG_DB_PORT" required:"true"` EntityName string `envconfig:"PG_DB_ENTITY_NAME" default:"postgres"` DatabaseName string `envconfig:"PG_DB_NAME" required:"true"` IsTLSEnabled bool `envconfig:"PG_DB_TLS_ENABLED" default:"false"` }
type DBClient ¶
type DBClient struct {
// contains filtered or unexported fields
}
func NewDBClient ¶
NewDBClient returns new DB client instance
func (*DBClient) Delete ¶
Delete delete value match given conditions, if the value has primary key, then will including the primary key as condition Save update value in database, if the value doesn't have primary key, will insert it
func (*DBClient) FindWithOrder ¶
FindWithOrder Find find records that match given conditions with the provided order
Click to show internal directories.
Click to hide internal directories.