Documentation
¶
Index ¶
- Variables
- type Driver
- type Engine
- func (e *Engine) Begin() (*Session, error)
- func (e *Engine) BeginWithContext(ctx context.Context) (*Session, error)
- func (e *Engine) Close() error
- func (e *Engine) DB() *sql.DB
- func (e *Engine) Driver() Driver
- func (e *Engine) NewSession() *Session
- func (e *Engine) NewSessionWithContext(ctx context.Context) *Session
- type EngineConfig
- type EngineOption
- type MySQLDriver
- type PostgresDriver
- type SQLiteDriver
- type Session
- func (s *Session) Close() error
- func (s *Session) Commit() error
- func (s *Session) Context() context.Context
- func (s *Session) Delete(tbl interface{}) *query.DeleteBuilder
- func (s *Session) Engine() *Engine
- func (s *Session) Exec(query string, args ...interface{}) (sql.Result, error)
- func (s *Session) GetTableColumns(tbl interface{}) []*table.ColumnRef
- func (s *Session) GetTableName(tbl interface{}) string
- func (s *Session) InTransaction() bool
- func (s *Session) Insert(tbl interface{}) *query.InsertBuilder
- func (s *Session) Query(tbl interface{}) *query.SelectBuilder
- func (s *Session) QueryRow(query string, args ...interface{}) *sql.Row
- func (s *Session) QueryRows(query string, args ...interface{}) (*sql.Rows, error)
- func (s *Session) Rollback() error
- func (s *Session) Update(tbl interface{}) *query.UpdateBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotInTransaction is returned when attempting transaction operations outside a transaction ErrNotInTransaction = errors.New("session is not in a transaction") // ErrAlreadyInTransaction is returned when attempting to start a transaction while already in one ErrAlreadyInTransaction = errors.New("session is already in a transaction") )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// Placeholder returns the placeholder format for this driver
// e.g., "?" for SQLite/MySQL, "$" for Postgres
Placeholder(position int) string
// SupportsReturning indicates if the driver supports RETURNING clauses
SupportsReturning() bool
// Quote quotes an identifier (table/column name)
Quote(identifier string) string
}
Driver represents a SQL dialect driver
func DriverByName ¶
DriverByName returns a driver by name
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine manages database connections and sessions
func NewEngine ¶
func NewEngine(db *sql.DB, opts ...EngineOption) *Engine
NewEngine creates a new database engine
func (*Engine) BeginWithContext ¶
BeginWithContext starts a new transaction with a context
func (*Engine) NewSession ¶
NewSession creates a new session for executing queries
type EngineConfig ¶
EngineConfig holds engine configuration
type EngineOption ¶
type EngineOption func(*EngineConfig)
EngineOption is a functional option for configuring an Engine
type MySQLDriver ¶
type MySQLDriver struct{}
MySQLDriver implements the Driver interface for MySQL
func (*MySQLDriver) Placeholder ¶
func (d *MySQLDriver) Placeholder(position int) string
func (*MySQLDriver) Quote ¶
func (d *MySQLDriver) Quote(identifier string) string
func (*MySQLDriver) SupportsReturning ¶
func (d *MySQLDriver) SupportsReturning() bool
type PostgresDriver ¶
type PostgresDriver struct{}
PostgresDriver implements the Driver interface for PostgreSQL
func (*PostgresDriver) Placeholder ¶
func (d *PostgresDriver) Placeholder(position int) string
func (*PostgresDriver) Quote ¶
func (d *PostgresDriver) Quote(identifier string) string
func (*PostgresDriver) SupportsReturning ¶
func (d *PostgresDriver) SupportsReturning() bool
type SQLiteDriver ¶
type SQLiteDriver struct{}
SQLiteDriver implements the Driver interface for SQLite
func (*SQLiteDriver) Placeholder ¶
func (d *SQLiteDriver) Placeholder(position int) string
func (*SQLiteDriver) Quote ¶
func (d *SQLiteDriver) Quote(identifier string) string
func (*SQLiteDriver) SupportsReturning ¶
func (d *SQLiteDriver) SupportsReturning() bool
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a database session for executing queries
func (*Session) Delete ¶
func (s *Session) Delete(tbl interface{}) *query.DeleteBuilder
Delete creates a new DELETE query builder
func (*Session) GetTableColumns ¶
GetTableColumns extracts column references from a Table[T] object
func (*Session) GetTableName ¶
GetTableName extracts the table name from a Table[T] object
func (*Session) InTransaction ¶
InTransaction returns true if the session is in a transaction
func (*Session) Insert ¶
func (s *Session) Insert(tbl interface{}) *query.InsertBuilder
Insert creates a new INSERT query builder
func (*Session) Query ¶
func (s *Session) Query(tbl interface{}) *query.SelectBuilder
Query creates a new SELECT query builder
func (*Session) Rollback ¶
Rollback rolls back the transaction (only valid if session is in a transaction)
func (*Session) Update ¶
func (s *Session) Update(tbl interface{}) *query.UpdateBuilder
Update creates a new UPDATE query builder