Documentation
¶
Overview ¶
Package runtime provides runtime utilities for the ORM.
Index ¶
- Variables
- type Config
- type DB
- func (db *DB) Begin(ctx context.Context) (pgx.Tx, error)
- func (db *DB) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (db *DB) Close()
- func (db *DB) Exec(ctx context.Context, sql string, args ...any) (int64, error)
- func (db *DB) Ping(ctx context.Context) error
- func (db *DB) Pool() *pgxpool.Pool
- func (db *DB) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
- type MigrationError
- type QueryError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when a record is not found. ErrNotFound = errors.New("record not found") // ErrInvalidModel is returned when an invalid model is provided. ErrInvalidModel = errors.New("invalid model") // ErrNoPrimaryKey is returned when a table has no primary key. ErrNoPrimaryKey = errors.New("no primary key defined") // ErrDuplicateKey is returned when a unique constraint is violated. ErrDuplicateKey = errors.New("duplicate key value") // ErrForeignKeyViolation is returned when a foreign key constraint is violated. ErrForeignKeyViolation = errors.New("foreign key violation") // ErrInvalidType is returned when a type conversion fails. ErrInvalidType = errors.New("invalid type") // ErrTransactionClosed is returned when operating on a closed transaction. ErrTransactionClosed = errors.New("transaction already closed") // ErrNoConnection is returned when no database connection is available. ErrNoConnection = errors.New("no database connection") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string
Port int
Database string
User string
Password string
SSLMode string
MaxConns int32
MinConns int32
}
Config represents database configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default database configuration.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a database connection.
func ConnectWithURL ¶
ConnectWithURL creates a new DB instance using a connection URL.
type MigrationError ¶
MigrationError represents a migration error.
func (*MigrationError) Error ¶
func (e *MigrationError) Error() string
Error implements the error interface.
func (*MigrationError) Unwrap ¶
func (e *MigrationError) Unwrap() error
Unwrap returns the underlying error.
type QueryError ¶
QueryError represents a query execution error.
func (*QueryError) Error ¶
func (e *QueryError) Error() string
Error implements the error interface.
func (*QueryError) Unwrap ¶
func (e *QueryError) Unwrap() error
Unwrap returns the underlying error.
type ValidationError ¶
ValidationError represents a validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
Click to show internal directories.
Click to hide internal directories.