Documentation ¶
Index ¶
- Variables
- func ConnectPgxPool(ctx context.Context, c Config) error
- func ConnectStdLib(ctx context.Context, c Config) error
- func Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func MigrateEntryPoint(config Config, optionally1EmbeddedDirs ...embed.FS)
- func MigrateGetDbDriver(ctx context.Context, c Config) (pgDatabaseDriver database.Driver, err error)
- func MigrateGetInstance(ctx context.Context, c Config, embeddedDirs ...embed.FS) (migrateInstance *migrate.Migrate, err error)
- func MigrateGetSource(ctx context.Context, c Config, embeddedDirs ...embed.FS) (migrationSourceDriver source.Driver, err error)
- func MigrateGetSourceFs(ctx context.Context, c Config, embeddedDirs ...embed.FS) (migrationFS fs.FS, err error)
- func QbExec(ctx context.Context, builtQuery sq.Sqlizer) (pgconn.CommandTag, error)
- func QbQuery(ctx context.Context, builtQuery sq.Sqlizer) (pgx.Rows, error)
- func QbQueryRow(ctx context.Context, builtQuery sq.Sqlizer) (pgx.Row, error)
- func Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- type Config
Constants ¶
This section is empty.
Variables ¶
var DbPool *pgxpool.Pool
DbPool is PGX pool connection, initiated by ConnectPgxPool. Do not use before the initialization.
var Qb adaptedStatementBuilder
Qb is the query builder exported, initiated from either ConnectStdLib or ConnectPgxPool
var StdDb *sql.DB
StdDb is pgx's stadard library SQL adaptor, initiated by ConnectStdLib. Do not use before the initialization.
Functions ¶
func ConnectPgxPool ¶
ConnectPgxPool initializes the PGX pool connection
func ConnectStdLib ¶
ConnectStdLib initiate the connection to database with pgx stdlib
func MigrateEntryPoint ¶
MigrateEntryPoint is the entrypoint for DB migration commands. If config.MigrationFromEmbedded is true, the (optional) embedded migration directory must then be set (only 1 is accepted)
the simplest way to include the embed:
import "embed" //go:embed migrations var embeddedMigrations embed.FS
func MigrateGetDbDriver ¶ added in v0.0.4
func MigrateGetDbDriver(ctx context.Context, c Config) (pgDatabaseDriver database.Driver, err error)
MigrateGetDbDriver exposes the lower-level migration integration
func MigrateGetInstance ¶ added in v0.0.4
func MigrateGetInstance(ctx context.Context, c Config, embeddedDirs ...embed.FS) (migrateInstance *migrate.Migrate, err error)
MigrateGetInstance exposes the lower-level migration integration
func MigrateGetSource ¶ added in v0.0.4
func MigrateGetSource(ctx context.Context, c Config, embeddedDirs ...embed.FS) (migrationSourceDriver source.Driver, err error)
MigrateGetSource exposes the lower-level migration integration
func MigrateGetSourceFs ¶ added in v0.0.5
func MigrateGetSourceFs(ctx context.Context, c Config, embeddedDirs ...embed.FS) (migrationFS fs.FS, err error)
MigrateGetSourceFs exposes the lower-level migration integration
func QbExec ¶ added in v0.0.6
QbExec takes a finished Squirrel's query builder and perform it using the default DbPool
func QbQuery ¶ added in v0.0.6
QbQuery takes a finished Squirrel's query builder and perform query using the default DbPool
func QbQueryRow ¶ added in v0.0.6
DoQuQeryRow takes a finished Squirrel's query builder and perform query using the default DbPool
Types ¶
type Config ¶
type Config struct { Host string `yaml:"Host" env:"PG_HOST"` Port int `yaml:"Port" env:"PG_PORT"` Database string `yaml:"Database" env:"PG_DATABASE"` Username string `yaml:"Username" env:"PG_USERNAME"` Password string `yaml:"Password" env:"PG_PASSWORD"` SSL string `yaml:"SSL" env:"PG_SSL"` MigrationStatementTimeoutSeconds int `yaml:"MigrationStatementTimeoutSeconds" env:"PG_MIGRATION_STATEMENT_TIMEOUT_SECONDS"` MigrationFromEmbedded bool `yaml:"MigrationFromEmbedded" env:"PG_MIGRATION_FROM_EMBEDDED"` MigrationDirectory string `yaml:"MigrationDirectory" env:"PG_MIGRATION_DIRECTORY"` }