Documentation ¶
Index ¶
- Variables
- func QuoteIdentifier(name string) string
- func QuoteLiteral(literal string) string
- func WithDatabase(ctx context.Context, database Database) context.Context
- type ConnectionInfo
- type Database
- type DbError
- type ExecuteQueryResult
- type ExecuteStatementResult
- type GormDB
- func (db *GormDB) Close() error
- func (db *GormDB) ExecuteQuery(ctx context.Context, sqlQuery string, args ...any) (*ExecuteQueryResult, error)
- func (db *GormDB) ExecuteStatement(ctx context.Context, sqlQuery string, args ...any) (*ExecuteStatementResult, error)
- func (db *GormDB) GetDB() *gorm.DB
- func (db *GormDB) Transaction(ctx context.Context, fn func(context.Context) error) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( PgNotNullConstraintViolation = "23502" PgForeignKeyConstraintViolation = "23503" PgUniqueConstraintViolation = "23505" )
Functions ¶
func QuoteIdentifier ¶
func QuoteLiteral ¶
Types ¶
type ConnectionInfo ¶
type ConnectionInfo struct { Host string Port string Username string Password string Database string }
func (*ConnectionInfo) ServerString ¶
func (dbConnInfo *ConnectionInfo) ServerString() string
func (*ConnectionInfo) String ¶
func (dbConnInfo *ConnectionInfo) String() string
func (*ConnectionInfo) WithDatabase ¶
func (dbConnInfo *ConnectionInfo) WithDatabase(database string) *ConnectionInfo
type Database ¶
type Database interface { // Executes SQL query statement and returns rows. ExecuteQuery(ctx context.Context, sql string, args ...any) (*ExecuteQueryResult, error) // Executes SQL statement and returns number of rows affected. ExecuteStatement(ctx context.Context, sql string, args ...any) (*ExecuteStatementResult, error) // Runs fn inside a transaction which is commited if fn returns a nil error Transaction(ctx context.Context, fn func(ctx context.Context) error) error Close() error GetDB() *gorm.DB }
type DbError ¶
type DbError struct { // if the error was associated with a specific table, the name of the table Table string // if the error was associated with specific table columns, the names of these columns Columns []string // the primary human-readable error message. This should be accurate but terse (typically one line). Always present Message string // the SQLSTATE code for the error - https://www.postgresql.org/docs/current/errcodes-appendix.html. Always present PgErrCode string // the underlying error Err error }
type ExecuteQueryResult ¶
type ExecuteStatementResult ¶
type ExecuteStatementResult struct {
RowsAffected int64
}
type GormDB ¶
type GormDB struct {
// contains filtered or unexported fields
}
func (*GormDB) ExecuteQuery ¶
func (*GormDB) ExecuteStatement ¶
Click to show internal directories.
Click to hide internal directories.