Documentation
¶
Index ¶
- type DBManager
- func (m *DBManager) AddConnection(name, driverName, dsn string, maxOpen, maxIdle int) error
- func (m *DBManager) Close() error
- func (m *DBManager) GetConnection(name string) *sql.DB
- func (m *DBManager) GetConnectionNames() []string
- func (m *DBManager) GetDefault() (*sql.DB, Dialect)
- func (m *DBManager) GetDialect(name string) Dialect
- func (m *DBManager) SetDefault(name string) error
- type Dialect
- type MySQLDialect
- type PostgreSQLDialect
- type SQLServerDialect
- type SQLiteDialect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBManager ¶
type DBManager struct {
// contains filtered or unexported fields
}
DBManager mengelola multiple database connections
func (*DBManager) AddConnection ¶
AddConnection menambahkan koneksi database baru driverName: nama driver database (contoh: "mysql", "sqlite") name: nama identifier untuk koneksi (contoh: "default", "warehouse", "analytics") dsn: Data Source Name (format tergantung driver)
func (*DBManager) GetConnection ¶
GetConnection mengambil koneksi database berdasarkan nama Mengembalikan nil jika tidak ditemukan
func (*DBManager) GetConnectionNames ¶
GetConnectionNames mengembalikan daftar semua nama koneksi
func (*DBManager) GetDefault ¶
GetDefault mengambil koneksi database default (primary)
func (*DBManager) GetDialect ¶
GetDialect mengambil dialect database berdasarkan nama koneksi
func (*DBManager) SetDefault ¶
SetDefault mengubah nama koneksi default
type Dialect ¶
type Dialect interface {
Name() string
QuoteIdentifier(name string) string
Placeholder(n int) string
Limit(limit, offset int) string
}
Dialect abstraction for different SQL databases
func GetDialect ¶
GetDialect returns the appropriate dialect for the driver name
type MySQLDialect ¶
type MySQLDialect struct{}
MySQLDialect implementation
func (MySQLDialect) Limit ¶
func (d MySQLDialect) Limit(limit, offset int) string
func (MySQLDialect) Name ¶
func (d MySQLDialect) Name() string
func (MySQLDialect) Placeholder ¶
func (d MySQLDialect) Placeholder(n int) string
func (MySQLDialect) QuoteIdentifier ¶
func (d MySQLDialect) QuoteIdentifier(name string) string
type PostgreSQLDialect ¶
type PostgreSQLDialect struct{}
PostgreSQLDialect implementation
func (PostgreSQLDialect) Limit ¶
func (d PostgreSQLDialect) Limit(limit, offset int) string
func (PostgreSQLDialect) Name ¶
func (d PostgreSQLDialect) Name() string
func (PostgreSQLDialect) Placeholder ¶
func (d PostgreSQLDialect) Placeholder(n int) string
func (PostgreSQLDialect) QuoteIdentifier ¶
func (d PostgreSQLDialect) QuoteIdentifier(name string) string
type SQLServerDialect ¶
type SQLServerDialect struct{}
SQLServerDialect implementation
func (SQLServerDialect) Limit ¶
func (d SQLServerDialect) Limit(limit, offset int) string
func (SQLServerDialect) Name ¶
func (d SQLServerDialect) Name() string
func (SQLServerDialect) Placeholder ¶
func (d SQLServerDialect) Placeholder(n int) string
func (SQLServerDialect) QuoteIdentifier ¶
func (d SQLServerDialect) QuoteIdentifier(name string) string
type SQLiteDialect ¶
type SQLiteDialect struct{}
SQLiteDialect implementation
func (SQLiteDialect) Limit ¶
func (d SQLiteDialect) Limit(limit, offset int) string
func (SQLiteDialect) Name ¶
func (d SQLiteDialect) Name() string
func (SQLiteDialect) Placeholder ¶
func (d SQLiteDialect) Placeholder(n int) string
func (SQLiteDialect) QuoteIdentifier ¶
func (d SQLiteDialect) QuoteIdentifier(name string) string