Versions in this module Expand all Collapse all v0 v0.1.0 Mar 11, 2025 Changes in this version + type ConfigFunc func(dbal *DBAL) error + func WithConnectionAdjuster(callback func(connection *sql.DB) error) ConfigFunc + func WithLogger(logger *log.Logger) ConfigFunc + func WithPostRunFunc(postRunFunc ConfigPostRunFunc) ConfigFunc + func WithPreRunFunc(preRunFunc ConfigPreRunFunc) ConfigFunc + type ConfigPostRunFunc func(ctx context.Context) error + type ConfigPreRunFunc func(ctx context.Context, statement string, args []any) error type DBAL + func (dbal *DBAL) AutoMigrate(ctx context.Context, entities []Entity) error type Driver + AddColumn func(t Table, c TableColumn) string + AddForeignKey func(t Table, c TableForeignKey) string + AddIndex func(t Table, c TableIndex) string + AlterColumn func(t Table, c TableColumn) string + CreateTable func(t Table) string + Delete func(e Entity) (string, map[string]any, error) + DropColumn func(t Table, c TableColumn) string + DropForeignKey func(t Table, c TableForeignKey) string + DropIndex func(t Table, c TableIndex) string + DropTable func(t Table) string + Insert func(e Entity) (string, map[string]any, error) + ParseCreateTable func(s string) Table + RenameTable func(t Table) string + Save func(e Entity) (string, map[string]any, error) + Select func(e Entity) (Query, error) + ShowCreateTable func(tableName string) string + TableFromEntity func(e Entity) Table + Update func(e Entity) (string, map[string]any, error) + type DriverMySQL struct + Hostname string + Name string + Password string + Port int + Username string + func (driver DriverMySQL) AddColumn(t Table, c TableColumn) string + func (driver DriverMySQL) AddForeignKey(t Table, c TableForeignKey) string + func (driver DriverMySQL) AddIndex(t Table, c TableIndex) string + func (driver DriverMySQL) AlterColumn(t Table, c TableColumn) string + func (driver DriverMySQL) CreateTable(t Table) string + func (driver DriverMySQL) DSN() string + func (driver DriverMySQL) Delete(entity Entity) (string, map[string]any, error) + func (driver DriverMySQL) Driver() string + func (driver DriverMySQL) DropColumn(t Table, c TableColumn) string + func (driver DriverMySQL) DropForeignKey(t Table, c TableForeignKey) string + func (driver DriverMySQL) DropIndex(t Table, c TableIndex) string + func (driver DriverMySQL) DropTable(t Table) string + func (driver DriverMySQL) Insert(entity Entity) (string, map[string]any, error) + func (driver DriverMySQL) ParseCreateTable(s string) Table + func (driver DriverMySQL) RenameTable(t Table) string + func (driver DriverMySQL) Save(entity Entity) (string, map[string]any, error) + func (driver DriverMySQL) Select(entity Entity) (Query, error) + func (driver DriverMySQL) ShowCreateTable(tableName string) string + func (driver DriverMySQL) TableFromEntity(e Entity) Table + func (driver DriverMySQL) Update(entity Entity) (string, map[string]any, error) + type DriverPostgres struct + Hostname string + Name string + Password string + Port int + Username string + func (driver DriverPostgres) AddColumn(t Table, c TableColumn) string + func (driver DriverPostgres) AddForeignKey(t Table, c TableForeignKey) string + func (driver DriverPostgres) AddIndex(t Table, c TableIndex) string + func (driver DriverPostgres) AlterColumn(t Table, c TableColumn) string + func (driver DriverPostgres) CreateTable(t Table) string + func (driver DriverPostgres) DSN() string + func (driver DriverPostgres) Delete(entity Entity) (string, map[string]any, error) + func (driver DriverPostgres) Driver() string + func (driver DriverPostgres) DropColumn(t Table, c TableColumn) string + func (driver DriverPostgres) DropForeignKey(t Table, c TableForeignKey) string + func (driver DriverPostgres) DropIndex(t Table, c TableIndex) string + func (driver DriverPostgres) DropTable(t Table) string + func (driver DriverPostgres) Insert(entity Entity) (string, map[string]any, error) + func (driver DriverPostgres) ParseCreateTable(s string) Table + func (driver DriverPostgres) RenameTable(t Table) string + func (driver DriverPostgres) Save(entity Entity) (string, map[string]any, error) + func (driver DriverPostgres) Select(entity Entity) (Query, error) + func (driver DriverPostgres) ShowCreateTable(tableName string) string + func (driver DriverPostgres) TableFromEntity(entity Entity) Table + func (driver DriverPostgres) Update(entity Entity) (string, map[string]any, error) + type DriverSQLite struct + Path string + func (driver DriverSQLite) AddColumn(t Table, c TableColumn) string + func (driver DriverSQLite) AddForeignKey(t Table, c TableForeignKey) string + func (driver DriverSQLite) AddIndex(t Table, c TableIndex) string + func (driver DriverSQLite) AlterColumn(t Table, c TableColumn) string + func (driver DriverSQLite) CreateTable(t Table) string + func (driver DriverSQLite) DSN() string + func (driver DriverSQLite) Delete(entity Entity) (string, map[string]any, error) + func (driver DriverSQLite) Driver() string + func (driver DriverSQLite) DropColumn(t Table, c TableColumn) string + func (driver DriverSQLite) DropForeignKey(t Table, c TableForeignKey) string + func (driver DriverSQLite) DropIndex(t Table, c TableIndex) string + func (driver DriverSQLite) DropTable(t Table) string + func (driver DriverSQLite) Insert(entity Entity) (string, map[string]any, error) + func (driver DriverSQLite) ParseCreateTable(s string) Table + func (driver DriverSQLite) RenameTable(t Table) string + func (driver DriverSQLite) Save(entity Entity) (string, map[string]any, error) + func (driver DriverSQLite) Select(entity Entity) (Query, error) + func (driver DriverSQLite) ShowCreateTable(tableName string) string + func (driver DriverSQLite) TableFromEntity(entity Entity) Table + func (driver DriverSQLite) Update(entity Entity) (string, map[string]any, error) type EntityInformation + ForeignKey []TableForeignKey + Indexes []TableIndex type Repository + func (q *Repository[ID, T]) GetByID(ctx context.Context, id ID) (T, error) + type Table struct + Columns []TableColumn + Name string + type TableColumn struct + AutoIncrement bool + Default string + ForeignKey *TableForeignKey + HasDefault bool + Index []TableIndex + Name string + Nullable bool + PrimaryKey bool + Type string + type TableForeignKey struct + type TableIndex struct v0.0.5 Oct 3, 2024 Changes in this version + type Driver interface + DSN func() string + Driver func() string + GenerateDelete func(entity Entity) (string, map[string]any, error) + GenerateInsert func(entity Entity) (string, map[string]any, error) + GenerateSave func(entity Entity) (string, map[string]any, error) + GenerateSelect func(entity Entity) (Query, error) + GenerateUpdate func(entity Entity) (string, map[string]any, error) + type MySQL struct + Hostname string + Name string + Password string + Port int + Username string + func (g MySQL) Driver() string + func (g MySQL) GenerateDelete(entity Entity) (string, map[string]any, error) + func (g MySQL) GenerateInsert(entity Entity) (string, map[string]any, error) + func (g MySQL) GenerateSave(entity Entity) (string, map[string]any, error) + func (g MySQL) GenerateSelect(entity Entity) (Query, error) + func (g MySQL) GenerateUpdate(entity Entity) (string, map[string]any, error) + func (q MySQL) DSN() string v0.0.4 Aug 13, 2024 v0.0.3 Jun 20, 2024 v0.0.2 Jun 15, 2024 Changes in this version + type Config struct + Hostname string + Name string + Password string + Port int + Username string + func (c Config) DSN() string type DBAL + func (dbal *DBAL) Ping() error type QueryModifier + func WithAdditionalWhere(where string, parameters map[string]any) QueryModifier v0.0.1 Jun 15, 2024 Changes in this version + var ErrNoRows = errors.New("no rows") + func GenerateDelete(entity Entity) (string, map[string]any, error) + func GenerateInsert(entity Entity) (string, map[string]any, error) + func GenerateSave(entity Entity) (string, map[string]any, error) + func GenerateUpdate(entity Entity) (string, map[string]any, error) + func Prepare(statement string, parameters map[string]any) (string, []any, error) + type DBAL struct + func NewDBAL(connection *sql.DB, logger *log.Logger) *DBAL + func (dbal *DBAL) RawExecute(ctx context.Context, query string, parameters map[string]any) (sql.Result, error) + func (dbal *DBAL) RawSelect(ctx context.Context, query string, parameters map[string]any, ...) error + type Entity interface + EntityInformation func() EntityInformation + type EntityInformation struct + TableName string + type Query struct + From string + GroupBy string + Joins []string + Limit struct{ ... } + OrderBy string + Parameters map[string]any + Select []string + Where string + func GenerateSelect(entity Entity) (Query, error) + func ParseQuery(query string) (Query, error) + func (q Query) String() string + type QueryModifier func(query Query) Query + func WithLimitOverride(size int, offset int) QueryModifier + type Repository struct + func NewRepository[ID ~uint64, T Entity](dbal *DBAL) Repository[ID, T] + func (q *Repository[ID, T]) Insert(ctx context.Context, entity T) (ID, error) + func (q *Repository[ID, T]) Save(ctx context.Context, entity T) error + func (q *Repository[ID, T]) Update(ctx context.Context, entity T) error + type Selector struct + func NewSelector[T any](connection *DBAL, query Query) Selector[T] + func (q *Selector[T]) SelectMultiple(ctx context.Context, mods ...QueryModifier) ([]T, error) + func (q *Selector[T]) SelectSingle(ctx context.Context, mods ...QueryModifier) (T, error)