Documentation ¶
Index ¶
- Variables
- func ConnectPgxPool(c Config) error
- func ConnectStdLib(c Config) error
- func DoExec(ctx context.Context, builtQuery squirrelBuiltQuery) (pgconn.CommandTag, error)
- func DoQuery(ctx context.Context, builtQuery squirrelBuiltQuery) (pgx.Rows, error)
- func DoQueryRow(ctx context.Context, builtQuery squirrelBuiltQuery) (pgx.Row, error)
- func MigrateEntryPoint(config Config, optionally1EmbeddedDirs ...embed.FS)
- type Config
Constants ¶
This section is empty.
Variables ¶
var DbPool *pgxpool.Pool
DbPool is PGX pool connection to be used inside this application
var Qb sq.StatementBuilderType
Qb is the query builder exported, initiated from Connect function
var StdDb *sql.DB
StdDb is exported for any database connected tasks / usage, it should be initiated using ConnectStdLib function
Functions ¶
func ConnectPgxPool ¶
ConnectPgxPool initializes the PGX pool connection
func ConnectStdLib ¶
ConnectStdLib initiate the connection to database with pgx stdlib
func DoExec ¶
func DoExec(ctx context.Context, builtQuery squirrelBuiltQuery) (pgconn.CommandTag, error)
DoExec takes a finished Squirrel's query builder and perform it using PGX
func DoQueryRow ¶
DoQueryRow takes a finished Squirrel's query builder and perform query using PGX
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
Types ¶
type Config ¶
type Config struct { Host string `yaml:"Host"` Port int `yaml:"Port"` Database string `yaml:"Database"` Username string `yaml:"Username"` Password string `yaml:"Password"` SSL string `yaml:"SSL"` MigrationStatementTimeoutSeconds int `yaml:"migrationStatementTimeoutSeconds"` MigrationFromEmbedded bool `yaml:"MigrationFromEmbedded"` MigrationDirectory string `yaml:"MigrationDirectory"` }