Documentation
¶
Overview ¶
Package types contains the core database interface definitions for go-bricks. These interfaces are separate from the main database package to avoid import cycles and to make them easily accessible for mocking and testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
// Query execution
Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRow(ctx context.Context, query string, args ...any) *sql.Row
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
// Prepared statements
Prepare(ctx context.Context, query string) (Statement, error)
// Transaction support
Begin(ctx context.Context) (Tx, error)
BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
// Health and diagnostics
Health(ctx context.Context) error
Stats() (map[string]any, error)
// Connection management
Close() error
// Database-specific features
DatabaseType() string
// Migration support
GetMigrationTable() string
CreateMigrationTable(ctx context.Context) error
}
Interface defines the common database operations supported by the framework. This is the main interface that applications and modules should depend on for database operations, allowing for easy mocking and testing.
type Statement ¶
type Statement interface {
// Query execution
Query(ctx context.Context, args ...any) (*sql.Rows, error)
QueryRow(ctx context.Context, args ...any) *sql.Row
Exec(ctx context.Context, args ...any) (sql.Result, error)
// Statement management
Close() error
}
Statement defines the interface for prepared statements
type Tx ¶
type Tx interface {
// Query execution within transaction
Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRow(ctx context.Context, query string, args ...any) *sql.Row
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
// Prepared statements within transaction
Prepare(ctx context.Context, query string) (Statement, error)
// Transaction control
Commit() error
Rollback() error
}
Tx defines the interface for database transactions
Click to show internal directories.
Click to hide internal directories.