Documentation
¶
Overview ¶
Package database opens supported GORM SQL drivers and exposes driver metadata.
MapLoadError and MapPersistError classify GORM errors into D10 categories (not_found, conflict, internal) so generated handlers, admin, and auth share one unique-violation detector instead of three copies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsUniqueViolation ¶ added in v0.1.3
IsUniqueViolation reports duplicate-key errors. Open does not set gorm.Config.TranslateError, so ErrDuplicatedKey is usually unset and the driver error string is the portable signal across SQLite, Postgres, and MySQL.
func MapLoadError ¶ added in v0.1.3
MapLoadError maps a GORM read/load error to a D10 category error: record-not-found becomes not_found; any other driver failure becomes internal. Unique/duplicate is not treated as conflict on load.
Types ¶
type Capabilities ¶
type Capabilities struct {
Transactions bool
Savepoints bool
ForeignKeyConstraints bool
Returning bool
Upsert bool
AdvisoryLocks bool
ConcurrentIndexBuilds bool
}
Capabilities names behavior that differs across supported database drivers.
func CapabilitiesFor ¶
func CapabilitiesFor(driver Driver) Capabilities
CapabilitiesFor returns the capability model for driver.
type DB ¶
DB is an opened GORM database with Gombit driver metadata.
func Open ¶
func Open(cfg config.DatabaseConfig) (*DB, error)
Open opens a GORM database for a supported config.DatabaseConfig.
func (*DB) Capabilities ¶
func (db *DB) Capabilities() Capabilities
Capabilities returns the configured driver's capability flags.
type Driver ¶
type Driver string
Driver names a supported database driver.
const ( // DriverSQLite identifies SQLite. DriverSQLite Driver = Driver(config.DatabaseDriverSQLite) // DriverPostgres identifies PostgreSQL. DriverPostgres Driver = Driver(config.DatabaseDriverPostgres) // DriverMySQL identifies MySQL. DriverMySQL Driver = Driver(config.DatabaseDriverMySQL) )