Documentation
¶
Index ¶
- Constants
- Variables
- func BuildDSN(user, password, host, database string, port uint, queryOpts ...string) *url.URL
- func New() modules.Module
- func WithDSN(dsn string) modules.Option
- func WithDatabase(database string) modules.Option
- func WithHost(host string) modules.Option
- func WithMigrations(cfg *MigrationsConfig) modules.Option
- func WithMigrationsLocation(location string) modules.Option
- func WithMigrationsSchemaName(schemaName string) modules.Option
- func WithMigrationsTable(table string) modules.Option
- func WithPassword(password string) modules.Option
- func WithPort(port uint) modules.Option
- func WithUser(user string) modules.Option
- type CloseTx
- type ExecOption
- type Executor
- type Migrations
- type MigrationsConfig
- type Module
- type Querier
- type Tx
Constants ¶
const (
ModuleName = "postgresdb"
)
Variables ¶
Functions ¶
func WithDatabase ¶
func WithMigrations ¶
func WithMigrations(cfg *MigrationsConfig) modules.Option
func WithMigrationsLocation ¶
func WithMigrationsTable ¶
func WithPassword ¶
Types ¶
type ExecOption ¶
type ExecOption func(*Executor)
func WithFilter ¶
func WithFilter(filter query.Filter) ExecOption
WithFilter sets the query.Filter option, which applies all filters to all queries that are to be executed on a executor where this option is passed to. To remove filters from a query, nil or query.Filter{} should be passed here.
func WithLimit ¶
func WithLimit(limit query.Limit) ExecOption
WithLimit sets the query.Limit option, which will apply the "OFFSET" and "LIMIT" statements to all the queries that will be executed with the executor this option is passed to. To remove limits from a query, nil or query.Filter{} should be passed here.
func WithOrderBy ¶
func WithOrderBy(orderBy query.OrderBy) ExecOption
WithOrderBy sets the query.OrderBy option, which applies the "ORDER BY" statement to all the queries that will be executed with the executor this option is passed to. To remove orders from a query, nil or query.Filter{} should be passed here.
func WithTransaction
deprecated
func WithTransaction(tx Tx) ExecOption
Deprecated: WithTransaction is no longer to be used as the Executor is now receiving a Querier interface which can be either a DBPool or a Transaction. WithTransaction sets the Tx transaction object to the executor. All queries executed on the executor where this option is given, will be executed using this transaction.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor provides the same query methods as pgx execution types, but extends them with support for ExecOptions. These options let users modify query behavior by applying criteria such as WHERE, LIMIT, or ORDER BY clauses.
func NewExecutor ¶
func NewExecutor(querier Querier, opts ...ExecOption) *Executor
NewExecutor instantiates the Executor with the Querier and applies ExecOptions to it.
type Migrations ¶
type Migrations struct {
// contains filtered or unexported fields
}
func InitMigrations ¶
func InitMigrations(cfg *MigrationsConfig) (*Migrations, error)
func (*Migrations) Close ¶
func (m *Migrations) Close() error
func (*Migrations) Down ¶
func (m *Migrations) Down() error
func (*Migrations) Up ¶
func (m *Migrations) Up() error