Documentation
¶
Overview ¶
Package models contains the database interaction model code
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Index ¶
- Constants
- Variables
- func InsertManyGoschemaMigrationHistorys(db DB, ms ...*GoschemaMigrationHistory) error
- func InsertManyGoschemaMigrationVersions(db DB, ms ...*GoschemaMigrationVersion) error
- func IsKeySet(x any) bool
- type DB
- type DBTransactionHandler
- type DBTransactioner
- type Deletable
- type GoschemaMigrationHistory
- func (m *GoschemaMigrationHistory) Delete(db DB) error
- func (m *GoschemaMigrationHistory) Insert(db DB) error
- func (m *GoschemaMigrationHistory) InsertWithUpdate(db DB) error
- func (m *GoschemaMigrationHistory) IsPrimaryKeySet() bool
- func (m *GoschemaMigrationHistory) Patch(db DB, newT *GoschemaMigrationHistory) error
- func (m *GoschemaMigrationHistory) Save(db DB) error
- func (m *GoschemaMigrationHistory) SaveOrUpdate(db DB) error
- func (m *GoschemaMigrationHistory) Update(db DB) error
- type GoschemaMigrationVersion
- func (m *GoschemaMigrationVersion) Delete(db DB) error
- func (m *GoschemaMigrationVersion) Insert(db DB) error
- func (m *GoschemaMigrationVersion) InsertWithUpdate(db DB) error
- func (m *GoschemaMigrationVersion) IsPrimaryKeySet() bool
- func (m *GoschemaMigrationVersion) Patch(db DB, newT *GoschemaMigrationVersion) error
- func (m *GoschemaMigrationVersion) Save(db DB) error
- func (m *GoschemaMigrationVersion) SaveOrUpdate(db DB) error
- func (m *GoschemaMigrationVersion) Update(db DB) error
- type LoggableDBTransactionHandler
- type PostDeletable
- type PostSaveable
- type PreDeletable
- type PreSaveable
- type Saveable
- type SetLogger
- type TransactionFunc
- type TransactionHandler
- type Transactioner
- type XODB
Constants ¶
const (
// GoschemaMigrationHistoryTableName is the name of the table for the GoschemaMigrationHistory model.
GoschemaMigrationHistoryTableName = "goschema_migration_history"
)
const (
// GoschemaMigrationVersionTableName is the name of the table for the GoschemaMigrationVersion model.
GoschemaMigrationVersionTableName = "goschema_migration_version"
)
Variables ¶
var ( GoschemaMigrationHistoryActionMigratingUp = usql.NewEnum("migrating_up") GoschemaMigrationHistoryActionMigratingDown = usql.NewEnum("migrating_down") GoschemaMigrationHistoryActionMigratedUp = usql.NewEnum("migrated_up") GoschemaMigrationHistoryActionMigratedDown = usql.NewEnum("migrated_down") GoschemaMigrationHistoryActionMigrationError = usql.NewEnum("migration_error") )
Valid values for the 'Action' enum column
var DBLog = func(string, ...any) {}
DBLog provides the log func used by generated queries.
var DatabaseLatency = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "database_latency", Help: "Duration of database queries", }, []string{"query"}, )
DatabaseLatency is the duration of database queries.
var ErrConstraintViolation = errors.New("constraint violation")
ErrConstraintViolation is returned if a constraint is violated
var ErrDuplicate = errors.New("duplicate entry")
ErrDuplicate is returned if a duplicate entry is found
var ErrNoAffectedRows = errors.New("no affected rows")
ErrNoAffectedRows is returned if a model update affected no rows
var XOLog = func(msg string, args ...any) { DBLog(msg, args...) }
XOLog is a compat shim for DBLog
Functions ¶
func InsertManyGoschemaMigrationHistorys ¶ added in v0.0.15
func InsertManyGoschemaMigrationHistorys(db DB, ms ...*GoschemaMigrationHistory) error
func InsertManyGoschemaMigrationVersions ¶ added in v0.0.15
func InsertManyGoschemaMigrationVersions(db DB, ms ...*GoschemaMigrationVersion) error
Types ¶
type DB ¶ added in v0.0.15
type DB interface {
Exec(string, ...any) (sql.Result, error)
Query(string, ...any) (*sql.Rows, error)
QueryRow(string, ...any) *sql.Row
Get(dest any, query string, args ...any) error
Select(dest any, query string, args ...any) error
}
DB is the common interface for database operations
This should work with database/sql.DB and database/sql.Tx.
type DBTransactionHandler ¶ added in v0.0.15
type DBTransactionHandler struct {
// contains filtered or unexported fields
}
DBTransactionHandler handles a transaction that will return any error.
func NewDBTransactionHandler ¶ added in v0.0.15
func NewDBTransactionHandler(db Transactioner) *DBTransactionHandler
NewDBTransactionHandler returns a configured instance of DBTransactionHandler
func (*DBTransactionHandler) Handle ¶ added in v0.0.15
func (th *DBTransactionHandler) Handle(f TransactionFunc) error
Handle implements the TransactionHandler interface.
type DBTransactioner ¶ added in v0.0.15
type DBTransactioner interface {
DB
Transactioner
}
DBTransactioner is the interface that database connections that can utilise transactions should implement.
type Deletable ¶ added in v0.0.15
Deletable is the interface implemented by types which can delete themselves from the database.
type GoschemaMigrationHistory ¶ added in v0.0.15
type GoschemaMigrationHistory struct {
Id int `db:"id,pk,autoinc"`
Version string `db:"version"`
Action usql.Enum `db:"action"`
CreatedAt time.Time `db:"created_at"`
}
GoschemaMigrationHistory represents a row from 'goschema_migration_history'.
func GetAllGoschemaMigrationHistorys ¶ added in v0.0.25
func GetAllGoschemaMigrationHistorys(db DB, filters ...any) ([]*GoschemaMigrationHistory, error)
GetAllGoschemaMigrationHistorys retrieves all rows from 'goschema_migration_history' as a slice of GoschemaMigrationHistory.
Generated from table 'goschema_migration_history'.
func GoschemaMigrationHistoryById ¶ added in v0.0.15
func GoschemaMigrationHistoryById(db DB, id int) (*GoschemaMigrationHistory, error)
GoschemaMigrationHistoryById retrieves a row from 'goschema_migration_history' as a GoschemaMigrationHistory.
Generated from primary key.
func (*GoschemaMigrationHistory) Delete ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) Delete(db DB) error
Delete deletes the GoschemaMigrationHistory from the database.
func (*GoschemaMigrationHistory) Insert ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) Insert(db DB) error
Insert inserts the GoschemaMigrationHistory to the database.
func (*GoschemaMigrationHistory) InsertWithUpdate ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) InsertWithUpdate(db DB) error
InsertWithUpdate inserts the GoschemaMigrationHistory to the database, and tries to update on unique constraint violations.
func (*GoschemaMigrationHistory) IsPrimaryKeySet ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) IsPrimaryKeySet() bool
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*GoschemaMigrationHistory) Patch ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) Patch(db DB, newT *GoschemaMigrationHistory) error
Patch updates the GoschemaMigrationHistory in the database.
Generated from primary key.
func (*GoschemaMigrationHistory) Save ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) Save(db DB) error
Save saves the GoschemaMigrationHistory to the database.
func (*GoschemaMigrationHistory) SaveOrUpdate ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) SaveOrUpdate(db DB) error
SaveOrUpdate saves the GoschemaMigrationHistory to the database, but tries to update on unique constraint violations.
func (*GoschemaMigrationHistory) Update ¶ added in v0.0.15
func (m *GoschemaMigrationHistory) Update(db DB) error
Update updates the GoschemaMigrationHistory in the database.
type GoschemaMigrationVersion ¶ added in v0.0.15
type GoschemaMigrationVersion struct {
Version string `db:"version,pk"`
IsCurrent bool `db:"is_current"`
CreatedAt time.Time `db:"created_at"`
}
GoschemaMigrationVersion represents a row from 'goschema_migration_version'.
func GetAllGoschemaMigrationVersions ¶ added in v0.0.25
func GetAllGoschemaMigrationVersions(db DB, filters ...any) ([]*GoschemaMigrationVersion, error)
GetAllGoschemaMigrationVersions retrieves all rows from 'goschema_migration_version' as a slice of GoschemaMigrationVersion.
Generated from table 'goschema_migration_version'.
func GoschemaMigrationVersionByVersion ¶ added in v0.0.15
func GoschemaMigrationVersionByVersion(db DB, version string) (*GoschemaMigrationVersion, error)
GoschemaMigrationVersionByVersion retrieves a row from 'goschema_migration_version' as a GoschemaMigrationVersion.
Generated from primary key.
func (*GoschemaMigrationVersion) Delete ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) Delete(db DB) error
Delete deletes the GoschemaMigrationVersion from the database.
func (*GoschemaMigrationVersion) Insert ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) Insert(db DB) error
Insert inserts the GoschemaMigrationVersion to the database.
func (*GoschemaMigrationVersion) InsertWithUpdate ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) InsertWithUpdate(db DB) error
InsertWithUpdate inserts the GoschemaMigrationVersion to the database, and tries to update on unique constraint violations.
func (*GoschemaMigrationVersion) IsPrimaryKeySet ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) IsPrimaryKeySet() bool
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*GoschemaMigrationVersion) Patch ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) Patch(db DB, newT *GoschemaMigrationVersion) error
Patch updates the GoschemaMigrationVersion in the database.
Generated from primary key.
func (*GoschemaMigrationVersion) Save ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) Save(db DB) error
Save saves the GoschemaMigrationVersion to the database.
func (*GoschemaMigrationVersion) SaveOrUpdate ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) SaveOrUpdate(db DB) error
SaveOrUpdate saves the GoschemaMigrationVersion to the database, but tries to update on unique constraint violations.
func (*GoschemaMigrationVersion) Update ¶ added in v0.0.15
func (m *GoschemaMigrationVersion) Update(db DB) error
Update updates the GoschemaMigrationVersion in the database.
type LoggableDBTransactionHandler ¶ added in v0.0.15
type LoggableDBTransactionHandler struct {
// contains filtered or unexported fields
}
LoggableDBTransactionHandler handles a transaction and logs any error.
func NewLoggableDBTransactionHandler ¶ added in v0.0.15
func NewLoggableDBTransactionHandler(db Transactioner, l *slog.Logger) *LoggableDBTransactionHandler
NewLoggableDBTransactionHandler returns a configured instance of LoggableDBTransactionHandler
type PostDeletable ¶ added in v0.0.15
type PostDeletable interface {
PostDelete() error
}
PostDeletable is the interface implemented by types which run a post delete step.
type PostSaveable ¶ added in v0.0.15
type PostSaveable interface {
PostSave() error
}
PostSaveable is the interface implemented by types which run a post save step.
type PreDeletable ¶ added in v0.0.15
type PreDeletable interface {
PreDelete() error
}
PreDeletable is the interface implemented by types which run a pre delete step.
type PreSaveable ¶ added in v0.0.15
PreSaveable is the interface implemented by types which run a pre save step.
type Saveable ¶ added in v0.0.15
Saveable is the interface implemented by types which can save themselves to the database.
type SetLogger ¶ added in v0.0.15
SetLogger is the interface implemented by types which have the ability to configure their log entry.
type TransactionFunc ¶ added in v0.0.15
TransactionFunc is a function to be called within a transaction.
type TransactionHandler ¶ added in v0.0.15
type TransactionHandler interface {
Handle(TransactionFunc) error
}
type Transactioner ¶ added in v0.0.15
Transactioner is the interface that a database connection that can start a transaction should implement.