Documentation
¶
Index ¶
- func NewCannotCommitTxErrorConverter(tenantID string) errorex.ErrorConverter
- func NewConnector(tenantProvider dbconnector.TenantProvider) (dbconnector.Connector, error)
- func NewGenericDbErrorConverter(tenantID string) errorex.ErrorConverter
- type PgsqlConnector
- type PgsqlDatabase
- func (p *PgsqlDatabase) Close(ctx context.Context) error
- func (p *PgsqlDatabase) CreateTx(pgxTx pgx.Tx) *PgsqlTransaction
- func (p *PgsqlDatabase) PgxConn() *pgx.Conn
- func (p *PgsqlDatabase) Query(ctx context.Context, query string, args ...interface{}) (dbconnector.Rows, error)
- func (p *PgsqlDatabase) QueryRow(ctx context.Context, query string, args ...interface{}) dbconnector.Row
- func (p *PgsqlDatabase) RunInTransaction(ctx context.Context, fn dbconnector.TransactionFN) error
- func (p *PgsqlDatabase) TenantConfig() dbconnector.TenantConfig
- type PgsqlResult
- type PgsqlTransaction
- func (p *PgsqlTransaction) CommitOrRollback(ctx context.Context, err error) error
- func (p *PgsqlTransaction) Exec(ctx context.Context, query string, args ...interface{}) (dbconnector.Result, error)
- func (p *PgsqlTransaction) Query(ctx context.Context, query string, args ...interface{}) (dbconnector.Rows, error)
- func (p *PgsqlTransaction) QueryRow(ctx context.Context, query string, args ...interface{}) dbconnector.Row
- func (p *PgsqlTransaction) TenantConfig() dbconnector.TenantConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCannotCommitTxErrorConverter ¶
func NewCannotCommitTxErrorConverter(tenantID string) errorex.ErrorConverter
func NewConnector ¶
func NewConnector(tenantProvider dbconnector.TenantProvider) (dbconnector.Connector, error)
NewConnector creates a new database connector.
func NewGenericDbErrorConverter ¶
func NewGenericDbErrorConverter(tenantID string) errorex.ErrorConverter
Types ¶
type PgsqlConnector ¶
type PgsqlConnector struct {
// contains filtered or unexported fields
}
PgsqlConnector is the struct for the PostgreSQL connector.
func (*PgsqlConnector) Connect ¶
func (c *PgsqlConnector) Connect(ctx context.Context, tenantID string) (dbconnector.Database, error)
Connect connects to the database.
func (*PgsqlConnector) Reload ¶
func (c *PgsqlConnector) Reload() error
Reload reloads the tenants and reconfigure the database pool.
type PgsqlDatabase ¶
type PgsqlDatabase struct {
// contains filtered or unexported fields
}
PgsqlDatabase is the struct for the PostgreSQL database.
func (*PgsqlDatabase) CreateTx ¶
func (p *PgsqlDatabase) CreateTx(pgxTx pgx.Tx) *PgsqlTransaction
func (*PgsqlDatabase) PgxConn ¶
func (p *PgsqlDatabase) PgxConn() *pgx.Conn
PgxConn returns the pgx connection.
func (*PgsqlDatabase) Query ¶
func (p *PgsqlDatabase) Query(ctx context.Context, query string, args ...interface{}) (dbconnector.Rows, error)
Query executes a query.
func (*PgsqlDatabase) QueryRow ¶
func (p *PgsqlDatabase) QueryRow(ctx context.Context, query string, args ...interface{}) dbconnector.Row
QueryRow executes a query and returns a row.
func (*PgsqlDatabase) RunInTransaction ¶
func (p *PgsqlDatabase) RunInTransaction(ctx context.Context, fn dbconnector.TransactionFN) error
RunInTransaction runs a function in a transaction.
func (*PgsqlDatabase) TenantConfig ¶
func (p *PgsqlDatabase) TenantConfig() dbconnector.TenantConfig
TenantConfig returns the tenant config.
type PgsqlResult ¶
type PgsqlResult struct {
// contains filtered or unexported fields
}
PgsqlResult is the struct for the PostgreSQL result.
func (*PgsqlResult) LastInsertId ¶
func (p *PgsqlResult) LastInsertId() (int64, error)
LastInsertId returns the last insert id.
func (*PgsqlResult) RowsAffected ¶
func (p *PgsqlResult) RowsAffected() (int64, error)
RowsAffected returns the number of rows affected.
type PgsqlTransaction ¶
type PgsqlTransaction struct {
// contains filtered or unexported fields
}
PgsqlTransaction is the struct for the PostgreSQL transaction.
func (*PgsqlTransaction) CommitOrRollback ¶
func (p *PgsqlTransaction) CommitOrRollback(ctx context.Context, err error) error
CommitOrRollback commits or rollback the transaction based on the error.
func (*PgsqlTransaction) Exec ¶
func (p *PgsqlTransaction) Exec(ctx context.Context, query string, args ...interface{}) (dbconnector.Result, error)
Exec executes a query.
func (*PgsqlTransaction) Query ¶
func (p *PgsqlTransaction) Query(ctx context.Context, query string, args ...interface{}) (dbconnector.Rows, error)
Query executes a query.
func (*PgsqlTransaction) QueryRow ¶
func (p *PgsqlTransaction) QueryRow(ctx context.Context, query string, args ...interface{}) dbconnector.Row
QueryRow executes a query and returns a row.
func (*PgsqlTransaction) TenantConfig ¶
func (p *PgsqlTransaction) TenantConfig() dbconnector.TenantConfig
TenantConfig returns the tenant config.