Documentation
¶
Index ¶
- type Column
- type Condition
- type ConnectionConfig
- type Driver
- type Index
- type Join
- type Order
- type PostgresDriver
- func (d *PostgresDriver) Begin() (*sql.Tx, error)
- func (d *PostgresDriver) BeginTx() (*sql.Tx, error)
- func (d *PostgresDriver) Close() error
- func (d *PostgresDriver) Connect(config ConnectionConfig) error
- func (d *PostgresDriver) CreateTable(name string, definition func(*Table)) error
- func (d *PostgresDriver) DB() *sql.DB
- func (d *PostgresDriver) DriverName() string
- func (d *PostgresDriver) DropTable(name string) error
- func (d *PostgresDriver) Exec(query string, args ...any) (sql.Result, error)
- func (d *PostgresDriver) Grammar() QueryGrammar
- func (d *PostgresDriver) HasColumn(table, column string) bool
- func (d *PostgresDriver) HasTable(name string) bool
- func (d *PostgresDriver) Ping() error
- func (d *PostgresDriver) Query(query string, args ...any) (*sql.Rows, error)
- func (d *PostgresDriver) QueryRow(query string, args ...any) *sql.Row
- type PostgresGrammar
- func (g *PostgresGrammar) CompileCreateTable(name string, table *Table) string
- func (g *PostgresGrammar) CompileDelete(table string, conditions []Condition) (string, []any)
- func (g *PostgresGrammar) CompileDropTable(name string) string
- func (g *PostgresGrammar) CompileHasColumn(table, column string) string
- func (g *PostgresGrammar) CompileHasTable(name string) string
- func (g *PostgresGrammar) CompileInsert(table string, columns []string, values [][]any) (string, []any)
- func (g *PostgresGrammar) CompileSelect(query *SelectQuery) (string, []any)
- func (g *PostgresGrammar) CompileUpdate(table string, values map[string]any, conditions []Condition) (string, []any)
- func (g *PostgresGrammar) Placeholder(index int) string
- func (g *PostgresGrammar) QuoteIdentifier(name string) string
- func (g *PostgresGrammar) QuoteString(value string) string
- type QueryGrammar
- type SQLiteDriver
- func (d *SQLiteDriver) Begin() (*sql.Tx, error)
- func (d *SQLiteDriver) BeginTx() (*sql.Tx, error)
- func (d *SQLiteDriver) Close() error
- func (d *SQLiteDriver) Connect(config ConnectionConfig) error
- func (d *SQLiteDriver) CreateTable(name string, definition func(*Table)) error
- func (d *SQLiteDriver) DB() *sql.DB
- func (d *SQLiteDriver) DriverName() string
- func (d *SQLiteDriver) DropTable(name string) error
- func (d *SQLiteDriver) Exec(query string, args ...any) (sql.Result, error)
- func (d *SQLiteDriver) Grammar() QueryGrammar
- func (d *SQLiteDriver) HasColumn(table, column string) bool
- func (d *SQLiteDriver) HasTable(name string) bool
- func (d *SQLiteDriver) Ping() error
- func (d *SQLiteDriver) Query(query string, args ...any) (*sql.Rows, error)
- func (d *SQLiteDriver) QueryRow(query string, args ...any) *sql.Row
- type SQLiteGrammar
- func (g *SQLiteGrammar) CompileCreateTable(name string, table *Table) string
- func (g *SQLiteGrammar) CompileDelete(table string, conditions []Condition) (string, []any)
- func (g *SQLiteGrammar) CompileDropTable(name string) string
- func (g *SQLiteGrammar) CompileHasColumn(table, column string) string
- func (g *SQLiteGrammar) CompileHasTable(name string) string
- func (g *SQLiteGrammar) CompileInsert(table string, columns []string, values [][]any) (string, []any)
- func (g *SQLiteGrammar) CompileSelect(query *SelectQuery) (string, []any)
- func (g *SQLiteGrammar) CompileUpdate(table string, values map[string]any, conditions []Condition) (string, []any)
- func (g *SQLiteGrammar) Placeholder(index int) string
- func (g *SQLiteGrammar) QuoteIdentifier(name string) string
- func (g *SQLiteGrammar) QuoteString(value string) string
- type SelectQuery
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct {
Name string
Type string
Size int
Nullable bool
Default any
AutoIncrement bool
Primary bool
Unique bool
Comment string
}
Column represents a database column
type ConnectionConfig ¶
type ConnectionConfig struct {
Driver string
Host string
Port string
Database string
Username string
Password string
Charset string
Collation string
Prefix string
Schema string
SSLMode string
TimeZone string
MaxIdleConns int
MaxOpenConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
LogQueries bool
SlowQueryThreshold time.Duration
}
ConnectionConfig holds database connection settings
type Driver ¶
type Driver interface {
// Connection management
Connect(config ConnectionConfig) error
Close() error
Ping() error
DB() *sql.DB
// Query execution
Query(query string, args ...any) (*sql.Rows, error)
QueryRow(query string, args ...any) *sql.Row
Exec(query string, args ...any) (sql.Result, error)
// Transaction support
Begin() (*sql.Tx, error)
BeginTx() (*sql.Tx, error)
// Schema operations
CreateTable(name string, definition func(*Table)) error
DropTable(name string) error
HasTable(name string) bool
HasColumn(table, column string) bool
// Driver-specific
Grammar() QueryGrammar
DriverName() string
}
Driver defines the interface for all database drivers
func NewPostgresDriver ¶
func NewPostgresDriver() Driver
NewPostgresDriver creates a new PostgreSQL driver instance
func NewSQLiteDriver ¶
func NewSQLiteDriver() Driver
NewSQLiteDriver creates a new SQLite driver instance
type Join ¶
type Join struct {
Type string // INNER, LEFT, RIGHT, FULL
Table string
On string
Condition []Condition
}
Join represents a JOIN clause
type PostgresDriver ¶
type PostgresDriver struct {
// contains filtered or unexported fields
}
PostgresDriver implements the Driver interface for PostgreSQL
func (*PostgresDriver) Begin ¶
func (d *PostgresDriver) Begin() (*sql.Tx, error)
Begin starts a transaction
func (*PostgresDriver) BeginTx ¶
func (d *PostgresDriver) BeginTx() (*sql.Tx, error)
BeginTx starts a transaction with options
func (*PostgresDriver) Close ¶
func (d *PostgresDriver) Close() error
Close closes the database connection
func (*PostgresDriver) Connect ¶
func (d *PostgresDriver) Connect(config ConnectionConfig) error
Connect establishes a connection to PostgreSQL database
func (*PostgresDriver) CreateTable ¶
func (d *PostgresDriver) CreateTable(name string, definition func(*Table)) error
CreateTable creates a new table
func (*PostgresDriver) DB ¶
func (d *PostgresDriver) DB() *sql.DB
DB returns the underlying *sql.DB instance
func (*PostgresDriver) DriverName ¶
func (d *PostgresDriver) DriverName() string
DriverName returns the driver name
func (*PostgresDriver) DropTable ¶
func (d *PostgresDriver) DropTable(name string) error
DropTable drops a table
func (*PostgresDriver) Grammar ¶
func (d *PostgresDriver) Grammar() QueryGrammar
Grammar returns the PostgreSQL query grammar
func (*PostgresDriver) HasColumn ¶
func (d *PostgresDriver) HasColumn(table, column string) bool
HasColumn checks if a column exists in a table
func (*PostgresDriver) HasTable ¶
func (d *PostgresDriver) HasTable(name string) bool
HasTable checks if a table exists
func (*PostgresDriver) Ping ¶
func (d *PostgresDriver) Ping() error
Ping verifies the connection to the database
type PostgresGrammar ¶
type PostgresGrammar struct{}
PostgresGrammar implements QueryGrammar for PostgreSQL
func (*PostgresGrammar) CompileCreateTable ¶
func (g *PostgresGrammar) CompileCreateTable(name string, table *Table) string
CompileCreateTable compiles a CREATE TABLE query for PostgreSQL
func (*PostgresGrammar) CompileDelete ¶
func (g *PostgresGrammar) CompileDelete(table string, conditions []Condition) (string, []any)
CompileDelete compiles a DELETE query for PostgreSQL
func (*PostgresGrammar) CompileDropTable ¶
func (g *PostgresGrammar) CompileDropTable(name string) string
CompileDropTable compiles a DROP TABLE query for PostgreSQL
func (*PostgresGrammar) CompileHasColumn ¶
func (g *PostgresGrammar) CompileHasColumn(table, column string) string
CompileHasColumn compiles a query to check if column exists in PostgreSQL
func (*PostgresGrammar) CompileHasTable ¶
func (g *PostgresGrammar) CompileHasTable(name string) string
CompileHasTable compiles a query to check if table exists in PostgreSQL
func (*PostgresGrammar) CompileInsert ¶
func (g *PostgresGrammar) CompileInsert(table string, columns []string, values [][]any) (string, []any)
CompileInsert compiles an INSERT query for PostgreSQL
func (*PostgresGrammar) CompileSelect ¶
func (g *PostgresGrammar) CompileSelect(query *SelectQuery) (string, []any)
CompileSelect compiles a SELECT query for PostgreSQL
func (*PostgresGrammar) CompileUpdate ¶
func (g *PostgresGrammar) CompileUpdate(table string, values map[string]any, conditions []Condition) (string, []any)
CompileUpdate compiles an UPDATE query for PostgreSQL
func (*PostgresGrammar) Placeholder ¶
func (g *PostgresGrammar) Placeholder(index int) string
Placeholder returns the placeholder for prepared statements in PostgreSQL
func (*PostgresGrammar) QuoteIdentifier ¶
func (g *PostgresGrammar) QuoteIdentifier(name string) string
QuoteIdentifier quotes a database identifier for PostgreSQL
func (*PostgresGrammar) QuoteString ¶
func (g *PostgresGrammar) QuoteString(value string) string
QuoteString quotes a string value for PostgreSQL
type QueryGrammar ¶
type QueryGrammar interface {
// SELECT operations
CompileSelect(query *SelectQuery) (string, []any)
CompileInsert(table string, columns []string, values [][]any) (string, []any)
CompileUpdate(table string, values map[string]any, conditions []Condition) (string, []any)
CompileDelete(table string, conditions []Condition) (string, []any)
// Schema operations
CompileCreateTable(name string, table *Table) string
CompileDropTable(name string) string
CompileHasTable(name string) string
CompileHasColumn(table, column string) string
// Utilities
QuoteIdentifier(name string) string
QuoteString(value string) string
Placeholder(index int) string
}
QueryGrammar defines SQL dialect-specific query building
type SQLiteDriver ¶
type SQLiteDriver struct {
// contains filtered or unexported fields
}
SQLiteDriver implements the Driver interface for SQLite
func (*SQLiteDriver) Begin ¶
func (d *SQLiteDriver) Begin() (*sql.Tx, error)
Begin starts a transaction
func (*SQLiteDriver) BeginTx ¶
func (d *SQLiteDriver) BeginTx() (*sql.Tx, error)
BeginTx starts a transaction with options
func (*SQLiteDriver) Close ¶
func (d *SQLiteDriver) Close() error
Close closes the database connection
func (*SQLiteDriver) Connect ¶
func (d *SQLiteDriver) Connect(config ConnectionConfig) error
Connect establishes a connection to SQLite database
func (*SQLiteDriver) CreateTable ¶
func (d *SQLiteDriver) CreateTable(name string, definition func(*Table)) error
CreateTable creates a new table
func (*SQLiteDriver) DB ¶
func (d *SQLiteDriver) DB() *sql.DB
DB returns the underlying *sql.DB instance
func (*SQLiteDriver) DriverName ¶
func (d *SQLiteDriver) DriverName() string
DriverName returns the driver name
func (*SQLiteDriver) DropTable ¶
func (d *SQLiteDriver) DropTable(name string) error
DropTable drops a table
func (*SQLiteDriver) Grammar ¶
func (d *SQLiteDriver) Grammar() QueryGrammar
Grammar returns the SQLite query grammar
func (*SQLiteDriver) HasColumn ¶
func (d *SQLiteDriver) HasColumn(table, column string) bool
HasColumn checks if a column exists in a table
func (*SQLiteDriver) HasTable ¶
func (d *SQLiteDriver) HasTable(name string) bool
HasTable checks if a table exists
func (*SQLiteDriver) Ping ¶
func (d *SQLiteDriver) Ping() error
Ping verifies the connection to the database
type SQLiteGrammar ¶
type SQLiteGrammar struct{}
SQLiteGrammar implements QueryGrammar for SQLite
func (*SQLiteGrammar) CompileCreateTable ¶
func (g *SQLiteGrammar) CompileCreateTable(name string, table *Table) string
CompileCreateTable compiles a CREATE TABLE query
func (*SQLiteGrammar) CompileDelete ¶
func (g *SQLiteGrammar) CompileDelete(table string, conditions []Condition) (string, []any)
CompileDelete compiles a DELETE query
func (*SQLiteGrammar) CompileDropTable ¶
func (g *SQLiteGrammar) CompileDropTable(name string) string
CompileDropTable compiles a DROP TABLE query
func (*SQLiteGrammar) CompileHasColumn ¶
func (g *SQLiteGrammar) CompileHasColumn(table, column string) string
CompileHasColumn compiles a query to check if column exists
func (*SQLiteGrammar) CompileHasTable ¶
func (g *SQLiteGrammar) CompileHasTable(name string) string
CompileHasTable compiles a query to check if table exists
func (*SQLiteGrammar) CompileInsert ¶
func (g *SQLiteGrammar) CompileInsert(table string, columns []string, values [][]any) (string, []any)
CompileInsert compiles an INSERT query
func (*SQLiteGrammar) CompileSelect ¶
func (g *SQLiteGrammar) CompileSelect(query *SelectQuery) (string, []any)
CompileSelect compiles a SELECT query
func (*SQLiteGrammar) CompileUpdate ¶
func (g *SQLiteGrammar) CompileUpdate(table string, values map[string]any, conditions []Condition) (string, []any)
CompileUpdate compiles an UPDATE query
func (*SQLiteGrammar) Placeholder ¶
func (g *SQLiteGrammar) Placeholder(index int) string
Placeholder returns the placeholder for prepared statements
func (*SQLiteGrammar) QuoteIdentifier ¶
func (g *SQLiteGrammar) QuoteIdentifier(name string) string
QuoteIdentifier quotes a database identifier
func (*SQLiteGrammar) QuoteString ¶
func (g *SQLiteGrammar) QuoteString(value string) string
QuoteString quotes a string value