Documentation
¶
Index ¶
- func BulkInsert[T Table](executor gorp.SqlExecutor, db DB, allObjs ...T) error
- func ReplaceAll[T Table](db DB, objs ...T) error
- type DB
- func (d *DB) AddTable(t Table) *gorp.TableMap
- func (d *DB) CheckLivenessPeriodically(ctx context.Context)
- func (d *DB) Close()
- func (d *DB) CreateTable(table ...*gorp.TableMap) error
- func (d *DB) SelectTimed(group string, i any, query string, args ...any) ([]any, error)
- func (d *DB) TableExists(t Table) bool
- type Index
- type Migrater
- type Migration
- type Monitor
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BulkInsert ¶
func BulkInsert[T Table](executor gorp.SqlExecutor, db DB, allObjs ...T) error
Bulk insert objects into the database, using an executor which can be a transaction or a database connection itself.
Note: This function does NOT support auto-incrementing primary keys.
func ReplaceAll ¶
Replace all old objects of a table with new objects.
Types ¶
type DB ¶
Wrapper around gorp.DbMap that adds some convenience functions.
func NewPostgresDB ¶
func NewPostgresDB( ctx context.Context, c conf.DBConfig, registry *monitoring.Registry, monitor Monitor, ) DB
Create a new postgres database and wait until it is connected.
func (*DB) CheckLivenessPeriodically ¶
Check periodically if the database is alive. If not, panic.
func (*DB) CreateTable ¶
Adds missing functionality to gorp.DbMap which creates one table.
func (*DB) SelectTimed ¶
Executes a select query while monitoring its execution time.
func (*DB) TableExists ¶
Check if a table exists in the database.
type Migrater ¶
type Migrater interface {
Migrate(bool)
}
func NewMigrater ¶
Create a new migrater with files embedded in the binary.
type Migration ¶
type Migration struct {
FileName string `db:"file_name"`
}
Migration model to keep track which migrations have been executed.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
func NewDBMonitor ¶
func NewDBMonitor(registry *monitoring.Registry) Monitor