Documentation ¶
Index ¶
- Variables
- func ToURL(port int, ssl bool, username, password, db, host string) string
- type Config
- type ConnectPGOptions
- type Database
- func (d *Database) Close() error
- func (d *Database) GetMigrationVersion(ctx context.Context, v *uint) error
- func (d *Database) MigrateDown(ctx context.Context) error
- func (d *Database) MigrateUp(ctx context.Context, version *uint) error
- func (d *Database) Ping(ctx context.Context) (err error)
- func (d *Database) RunInTransaction(ctx context.Context, next func(ctx context.Context) error) error
- func (d *Database) TruncateAll() error
- type LogConErrorFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoRows is returned by QueryOne and ExecOne when query returned zero rows // but at least one row is expected. ErrNoRows = errors.New("pg: at least one row expected, none returned") // ErrMultiRows is returned by QueryOne and ExecOne when query returned // multiple rows but exactly one row is expected. ErrMultiRows = errors.New("pg: many rows returned, one expected") // ErrInvalidEnumValue typical error when the enum value is invalid ErrInvalidEnumValue = errors.New("pg: invalid value for enum") // ErrIntegrityViolation is returned when an integrity constraint is violated ErrIntegrityViolation = errors.New("pg: integrity violation") )
Functions ¶
Types ¶
type Config ¶
type Config struct { ConnectPGOptions SetInternalPGLogger bool PGApplicationName string PGLoggerPrefix string MigrationPath string PGPoolSize int }
Config is the service configuration
type ConnectPGOptions ¶
type ConnectPGOptions struct { ConnectionString string RetrySleepTime time.Duration RetryNumTimes uint16 // TLSConfig overrides any TLS config parsed from the connection string if not nil TLSConfig *tls.Config ConnErrorLogger LogConErrorFunc }
ConnectPGOptions attempts to connect to a pg instance; retries `RetryNumTimes`
type Database ¶
type Database struct { *pg.DB // contains filtered or unexported fields }
Database is a connection to a Postgres database.
func NewDatabase ¶
NewDatabase creates a new database connection.
func (*Database) GetMigrationVersion ¶
GetMigrationVersion returns what migration we are on.
func (*Database) MigrateDown ¶
MigrateDown performs a down migration.
func (*Database) RunInTransaction ¶
func (*Database) TruncateAll ¶
TruncateAll truncates all tables other that schema_migrations.
Click to show internal directories.
Click to hide internal directories.